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

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

Fix a segfault and add -cache-days-limit=N option

File size: 2.9 KB
RevLine 
[4801]1/*
[5391]2 *  Copyright (c) 2017 International Characters.
[4801]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
[5364]9
[5464]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
[5731]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
[5734]22#define LLVM_6_0_0 60000
[5731]23
[5732]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
[5731]31
[5464]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
[5267]36namespace llvm { namespace cl { class OptionCategory; } }
[5418]37
[5464]38namespace codegen {
[4801]39
[5771]40const llvm::cl::OptionCategory * LLVM_READONLY codegen_flags();
[4801]41
[5033]42// Command Parameters
[5295]43enum DebugFlags {
[5444]44    VerifyIR,
[5618]45    SerializeThreads,
[5637]46    TraceCounts,
[5721]47    TraceDynamicBuffers,
48    EnableAsserts,
49    EnableCycleCounter,
[5746]50    DisableIndirectBranch,
[5721]51    DebugFlagSentinel
[5295]52};
53
[5771]54bool LLVM_READONLY DebugOptionIsSet(const DebugFlags flag);
[5295]55
[5486]56extern bool PipelineParallel;
57extern bool SegmentPipelineParallel;
[5745]58   
59// Options for generating IR or ASM to files
60const std::string OmittedOption = ".";
61extern std::string ShowUnoptimizedIROption;
62extern std::string ShowIROption;
[5731]63#if LLVM_VERSION_INTEGER >= LLVM_3_7_0
[5745]64extern std::string ShowASMOption;
[5464]65#endif
[5486]66extern const char * ObjectCacheDir;
[5773]67extern unsigned CacheDaysLimit;  // set from command line
[5486]68extern llvm::CodeGenOpt::Level OptLevel;  // set from command line
[5757]69extern unsigned BlockSize;  // set from command line
70extern unsigned SegmentSize;  // set from command line
71extern unsigned BufferSegments;
72extern unsigned ThreadNum;
[5486]73extern bool EnableObjectCache;
[5151]74extern bool NVPTX;
[5757]75extern unsigned GroupNum;
[5486]76extern std::string ProgramName;
77extern llvm::TargetOptions Options;
[5464]78extern const llvm::Reloc::Model RelocModel;
79extern const llvm::CodeModel::Model CMModel;
80extern const std::string MArch;
81extern const std::string RunPass;
82extern const llvm::TargetMachine::CodeGenFileType FileType;
83extern const std::string StopAfter;
84extern const std::string StartAfter;
85
86std::string getCPUStr();
87std::string getFeaturesStr();
88void setFunctionAttributes(llvm::StringRef CPU, llvm::StringRef Features, llvm::Module &M);
89
[5486]90void ParseCommandLineOptions(int argc, const char *const *argv, std::initializer_list<const llvm::cl::OptionCategory *> hiding = {});
91
[5033]92}
[4900]93
[5373]94void AddParabixVersionPrinter();
95
[4801]96#endif
Note: See TracBrowser for help on using the repository browser.