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

Last change on this file since 5841 was 5841, checked in by cameron, 15 months ago

LLVM_VERSION_CODE macro, CC-multiplex option, performance bug fixes

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