source: icGREP/icgrep-devel/icgrep/toolchain/toolchain.h @ 5832

Last change on this file since 5832 was 5793, checked in by nmedfort, 20 months ago

Bug fix for pipeline: it was terminating too early when there was insufficient output space to process all of the input for a kernel.

File size: 2.9 KB
Line 
1/*
2 *  Copyright (c) 2017 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef TOOLCHAIN_H
8#define TOOLCHAIN_H
9
10#include <llvm/ADT/StringRef.h>
11#include <llvm/Support/CodeGen.h>
12#include <llvm/Target/TargetOptions.h>
13#include <llvm/Target/TargetMachine.h>
14
15// #defines for comparison with LLVM_VERSION_INTEGER
16#define LLVM_3_6_0 30600
17#define LLVM_3_7_0 30700
18#define LLVM_3_8_0 30800
19#define LLVM_3_9_0 30900
20#define LLVM_4_0_0 40000
21#define LLVM_5_0_0 50000
22#define LLVM_6_0_0 60000
23
24// From LLVM 4.0.0 the clEnumValEnd sentinel is no longer needed.
25// We define a macro to adapt to the CommandLine syntax based on LLVM version.
26#if LLVM_VERSION_INTEGER < LLVM_4_0_0
27#define CL_ENUM_VAL_SENTINEL , clEnumValEnd
28#else
29#define CL_ENUM_VAL_SENTINEL
30#endif
31
32// FIXME: llvm/CodeGen/CommandFlags.h can only be included once or the various cl::opt causes multiple definition
33// errors. To bypass for now, the relevant options and functions are accessible from here. Re-evaluate with later
34// versions of LLVM.
35
36namespace llvm { namespace cl { class OptionCategory; } }
37
38namespace codegen {
39
40const llvm::cl::OptionCategory * LLVM_READONLY codegen_flags();
41
42// Command Parameters
43enum DebugFlags {
44    VerifyIR,
45    SerializeThreads,
46    TraceCounts,
47    TraceDynamicBuffers,
48    EnableAsserts,
49    EnableCycleCounter,
50    DisableIndirectBranch,
51    DebugFlagSentinel
52};
53
54bool LLVM_READONLY DebugOptionIsSet(const DebugFlags flag);
55
56extern bool SegmentPipelineParallel;
57   
58// Options for generating IR or ASM to files
59const std::string OmittedOption = ".";
60extern std::string ShowUnoptimizedIROption;
61extern std::string ShowIROption;
62#if LLVM_VERSION_INTEGER >= LLVM_3_7_0
63extern std::string ShowASMOption;
64#endif
65extern const char * ObjectCacheDir;
66extern unsigned CacheDaysLimit;  // set from command line
67extern llvm::CodeGenOpt::Level OptLevel;  // set from command line
68extern unsigned BlockSize;  // set from command line
69extern unsigned SegmentSize;  // set from command line
70extern unsigned BufferSegments;
71extern unsigned ThreadNum;
72extern bool EnableObjectCache;
73extern bool NVPTX;
74extern unsigned GroupNum;
75extern std::string ProgramName;
76extern llvm::TargetOptions Options;
77extern const llvm::Reloc::Model RelocModel;
78extern const llvm::CodeModel::Model CMModel;
79extern const std::string MArch;
80extern const std::string RunPass;
81extern const llvm::TargetMachine::CodeGenFileType FileType;
82extern const std::string StopAfter;
83extern const std::string StartAfter;
84
85std::string getCPUStr();
86std::string getFeaturesStr();
87void setFunctionAttributes(llvm::StringRef CPU, llvm::StringRef Features, llvm::Module &M);
88
89void ParseCommandLineOptions(int argc, const char *const *argv, std::initializer_list<const llvm::cl::OptionCategory *> hiding = {});
90
91}
92
93void AddParabixVersionPrinter();
94
95#endif
Note: See TracBrowser for help on using the repository browser.