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

Last change on this file since 5732 was 5732, checked in by cameron, 20 months ago

More changes in preparation for LLVM 3.9, 4.0

File size: 2.7 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
23// From LLVM 4.0.0 the clEnumValEnd sentinel is no longer needed.
24// We define a macro to adapt to the CommandLine syntax based on LLVM version.
25#if LLVM_VERSION_INTEGER < LLVM_4_0_0
26#define CL_ENUM_VAL_SENTINEL , clEnumValEnd
27#else
28#define CL_ENUM_VAL_SENTINEL
29#endif
30
31// FIXME: llvm/CodeGen/CommandFlags.h can only be included once or the various cl::opt causes multiple definition
32// errors. To bypass for now, the relevant options and functions are accessible from here. Re-evaluate with later
33// versions of LLVM.
34
35namespace llvm { namespace cl { class OptionCategory; } }
36
37namespace codegen {
38
39const llvm::cl::OptionCategory * codegen_flags();
40
41// Command Parameters
42enum DebugFlags {
43    ShowUnoptimizedIR,
44    ShowIR,
45    VerifyIR,
46#if LLVM_VERSION_INTEGER >= LLVM_3_7_0
47    ShowASM,
48#endif
49    SerializeThreads,
50    TraceCounts,
51    TraceDynamicBuffers,
52    EnableAsserts,
53    EnableCycleCounter,
54    DebugFlagSentinel
55};
56
57bool DebugOptionIsSet(const DebugFlags flag);
58
59extern bool PipelineParallel;
60extern bool SegmentPipelineParallel;
61#if LLVM_VERSION_INTEGER >= LLVM_3_7_0
62extern const char * ASMOutputFilename;
63#endif
64extern const char * IROutputFilename;
65extern const char * ObjectCacheDir;
66extern llvm::CodeGenOpt::Level OptLevel;  // set from command line
67extern int BlockSize;  // set from command line
68extern int SegmentSize;  // set from command line
69extern int BufferSegments;
70extern int ThreadNum;
71extern bool EnableObjectCache;
72extern bool NVPTX;
73extern int GroupNum;
74extern std::string ProgramName;
75extern llvm::TargetOptions Options;
76extern const llvm::Reloc::Model RelocModel;
77extern const llvm::CodeModel::Model CMModel;
78extern const std::string MArch;
79extern const std::string RunPass;
80extern const llvm::TargetMachine::CodeGenFileType FileType;
81extern const std::string StopAfter;
82extern const std::string StartAfter;
83
84std::string getCPUStr();
85std::string getFeaturesStr();
86void setFunctionAttributes(llvm::StringRef CPU, llvm::StringRef Features, llvm::Module &M);
87
88void ParseCommandLineOptions(int argc, const char *const *argv, std::initializer_list<const llvm::cl::OptionCategory *> hiding = {});
89
90}
91
92void AddParabixVersionPrinter();
93
94bool AVX2_available();
95
96#endif
Note: See TracBrowser for help on using the repository browser.