Mercurial > hg > Members > tobaru > cbc > CbC_llvm
changeset 124:4fa72497ed5d
fix
author | mir3636 |
---|---|
date | Thu, 30 Nov 2017 20:04:56 +0900 |
parents | 923c9a525fb0 |
children | 56c5119fbcd2 |
files | include/llvm/CodeGen/Passes.h include/llvm/CodeGen/TargetPassConfig.h include/llvm/IR/Type.h include/llvm/Target/TargetOptions.h lib/CodeGen/TargetPassConfig.cpp |
diffstat | 5 files changed, 331 insertions(+), 608 deletions(-) [+] |
line wrap: on
line diff
--- a/include/llvm/CodeGen/Passes.h Thu Nov 30 18:21:27 2017 +0900 +++ b/include/llvm/CodeGen/Passes.h Thu Nov 30 20:04:56 2017 +0900 @@ -15,359 +15,25 @@ #ifndef LLVM_CODEGEN_PASSES_H #define LLVM_CODEGEN_PASSES_H -#include "llvm/Pass.h" -#include "llvm/Target/TargetMachine.h" #include <functional> #include <string> namespace llvm { +class FunctionPass; +class MachineFunction; class MachineFunctionPass; -class PassConfigImpl; -class PassInfo; -class ScheduleDAGInstrs; -class TargetLowering; -class TargetLoweringBase; +class ModulePass; +class Pass; +class TargetMachine; class TargetRegisterClass; class raw_ostream; -struct MachineSchedContext; -// The old pass manager infrastructure is hidden in a legacy namespace now. -namespace legacy { -class PassManagerBase; -} -using legacy::PassManagerBase; - -/// Discriminated union of Pass ID types. -/// -/// The PassConfig API prefers dealing with IDs because they are safer and more -/// efficient. IDs decouple configuration from instantiation. This way, when a -/// pass is overriden, it isn't unnecessarily instantiated. It is also unsafe to -/// refer to a Pass pointer after adding it to a pass manager, which deletes -/// redundant pass instances. -/// -/// However, it is convient to directly instantiate target passes with -/// non-default ctors. These often don't have a registered PassInfo. Rather than -/// force all target passes to implement the pass registry boilerplate, allow -/// the PassConfig API to handle either type. -/// -/// AnalysisID is sadly char*, so PointerIntPair won't work. -class IdentifyingPassPtr { - union { - AnalysisID ID; - Pass *P; - }; - bool IsInstance; -public: - IdentifyingPassPtr() : P(nullptr), IsInstance(false) {} - IdentifyingPassPtr(AnalysisID IDPtr) : ID(IDPtr), IsInstance(false) {} - IdentifyingPassPtr(Pass *InstancePtr) : P(InstancePtr), IsInstance(true) {} - - bool isValid() const { return P; } - bool isInstance() const { return IsInstance; } - - AnalysisID getID() const { - assert(!IsInstance && "Not a Pass ID"); - return ID; - } - Pass *getInstance() const { - assert(IsInstance && "Not a Pass Instance"); - return P; - } -}; - -template <> struct isPodLike<IdentifyingPassPtr> { - static const bool value = true; -}; - -/// Target-Independent Code Generator Pass Configuration Options. -/// -/// This is an ImmutablePass solely for the purpose of exposing CodeGen options -/// to the internals of other CodeGen passes. -class TargetPassConfig : public ImmutablePass { -public: - /// Pseudo Pass IDs. These are defined within TargetPassConfig because they - /// are unregistered pass IDs. They are only useful for use with - /// TargetPassConfig APIs to identify multiple occurrences of the same pass. - /// - - /// EarlyTailDuplicate - A clone of the TailDuplicate pass that runs early - /// during codegen, on SSA form. - static char EarlyTailDuplicateID; - - /// PostRAMachineLICM - A clone of the LICM pass that runs during late machine - /// optimization after regalloc. - static char PostRAMachineLICMID; - -private: - PassManagerBase *PM; - AnalysisID StartBefore, StartAfter; - AnalysisID StopAfter; - bool Started; - bool Stopped; - bool AddingMachinePasses; - -protected: - TargetMachine *TM; - PassConfigImpl *Impl; // Internal data structures - bool Initialized; // Flagged after all passes are configured. - - // Target Pass Options - // Targets provide a default setting, user flags override. - // - bool DisableVerify; - - /// Default setting for -enable-tail-merge on this target. - bool EnableTailMerge; - -public: - TargetPassConfig(TargetMachine *tm, PassManagerBase &pm); - // Dummy constructor. - TargetPassConfig(); - - ~TargetPassConfig() override; - - static char ID; - - /// Get the right type of TargetMachine for this target. - template<typename TMC> TMC &getTM() const { - return *static_cast<TMC*>(TM); - } - - // - void setInitialized() { Initialized = true; } - - CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); } -#ifndef noCbC - unsigned hasCodeSegment() { return TM->Options.HasCodeSegment; } -#endif - - /// Set the StartAfter, StartBefore and StopAfter passes to allow running only - /// a portion of the normal code-gen pass sequence. - /// - /// If the StartAfter and StartBefore pass ID is zero, then compilation will - /// begin at the normal point; otherwise, clear the Started flag to indicate - /// that passes should not be added until the starting pass is seen. If the - /// Stop pass ID is zero, then compilation will continue to the end. - /// - /// This function expects that at least one of the StartAfter or the - /// StartBefore pass IDs is null. - void setStartStopPasses(AnalysisID StartBefore, AnalysisID StartAfter, - AnalysisID StopAfter) { - if (StartAfter) - assert(!StartBefore && "Start after and start before passes are given"); - this->StartBefore = StartBefore; - this->StartAfter = StartAfter; - this->StopAfter = StopAfter; - Started = (StartAfter == nullptr) && (StartBefore == nullptr); - } - - void setDisableVerify(bool Disable) { setOpt(DisableVerify, Disable); } - - bool getEnableTailMerge() const { return EnableTailMerge; } - void setEnableTailMerge(bool Enable) { setOpt(EnableTailMerge, Enable); } - - /// Allow the target to override a specific pass without overriding the pass - /// pipeline. When passes are added to the standard pipeline at the - /// point where StandardID is expected, add TargetID in its place. - void substitutePass(AnalysisID StandardID, IdentifyingPassPtr TargetID); - - /// Insert InsertedPassID pass after TargetPassID pass. - void insertPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID, - bool VerifyAfter = true, bool PrintAfter = true); - - /// Allow the target to enable a specific standard pass by default. - void enablePass(AnalysisID PassID) { substitutePass(PassID, PassID); } - - /// Allow the target to disable a specific standard pass by default. - void disablePass(AnalysisID PassID) { - substitutePass(PassID, IdentifyingPassPtr()); - } - - /// Return the pass substituted for StandardID by the target. - /// If no substitution exists, return StandardID. - IdentifyingPassPtr getPassSubstitution(AnalysisID StandardID) const; - - /// Return true if the optimized regalloc pipeline is enabled. - bool getOptimizeRegAlloc() const; - - /// Return true if shrink wrapping is enabled. - bool getEnableShrinkWrap() const; - - /// Return true if the default global register allocator is in use and - /// has not be overriden on the command line with '-regalloc=...' - bool usingDefaultRegAlloc() const; - - /// Add common target configurable passes that perform LLVM IR to IR - /// transforms following machine independent optimization. - virtual void addIRPasses(); - - /// Add passes to lower exception handling for the code generator. - void addPassesToHandleExceptions(); - - /// Add pass to prepare the LLVM IR for code generation. This should be done - /// before exception handling preparation passes. - virtual void addCodeGenPrepare(); - - /// Add common passes that perform LLVM IR to IR transforms in preparation for - /// instruction selection. - virtual void addISelPrepare(); - - /// addInstSelector - This method should install an instruction selector pass, - /// which converts from LLVM code to machine instructions. - virtual bool addInstSelector() { - return true; - } - - /// Add the complete, standard set of LLVM CodeGen passes. - /// Fully developed targets will not generally override this. - virtual void addMachinePasses(); - - /// Create an instance of ScheduleDAGInstrs to be run within the standard - /// MachineScheduler pass for this function and target at the current - /// optimization level. - /// - /// This can also be used to plug a new MachineSchedStrategy into an instance - /// of the standard ScheduleDAGMI: - /// return new ScheduleDAGMI(C, make_unique<MyStrategy>(C), /*RemoveKillFlags=*/false) - /// - /// Return NULL to select the default (generic) machine scheduler. - virtual ScheduleDAGInstrs * - createMachineScheduler(MachineSchedContext *C) const { - return nullptr; - } - - /// Similar to createMachineScheduler but used when postRA machine scheduling - /// is enabled. - virtual ScheduleDAGInstrs * - createPostMachineScheduler(MachineSchedContext *C) const { - return nullptr; - } - -protected: - // Helper to verify the analysis is really immutable. - void setOpt(bool &Opt, bool Val); - - /// Methods with trivial inline returns are convenient points in the common - /// codegen pass pipeline where targets may insert passes. Methods with - /// out-of-line standard implementations are major CodeGen stages called by - /// addMachinePasses. Some targets may override major stages when inserting - /// passes is insufficient, but maintaining overriden stages is more work. - /// - - /// addPreISelPasses - This method should add any "last minute" LLVM->LLVM - /// passes (which are run just before instruction selector). - virtual bool addPreISel() { - return true; - } - - /// addMachineSSAOptimization - Add standard passes that optimize machine - /// instructions in SSA form. - virtual void addMachineSSAOptimization(); - - /// Add passes that optimize instruction level parallelism for out-of-order - /// targets. These passes are run while the machine code is still in SSA - /// form, so they can use MachineTraceMetrics to control their heuristics. - /// - /// All passes added here should preserve the MachineDominatorTree, - /// MachineLoopInfo, and MachineTraceMetrics analyses. - virtual bool addILPOpts() { - return false; - } - - /// This method may be implemented by targets that want to run passes - /// immediately before register allocation. - virtual void addPreRegAlloc() { } - - /// createTargetRegisterAllocator - Create the register allocator pass for - /// this target at the current optimization level. - virtual FunctionPass *createTargetRegisterAllocator(bool Optimized); - - /// addFastRegAlloc - Add the minimum set of target-independent passes that - /// are required for fast register allocation. - virtual void addFastRegAlloc(FunctionPass *RegAllocPass); - - /// addOptimizedRegAlloc - Add passes related to register allocation. - /// LLVMTargetMachine provides standard regalloc passes for most targets. - virtual void addOptimizedRegAlloc(FunctionPass *RegAllocPass); - - /// addPreRewrite - Add passes to the optimized register allocation pipeline - /// after register allocation is complete, but before virtual registers are - /// rewritten to physical registers. - /// - /// These passes must preserve VirtRegMap and LiveIntervals, and when running - /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix. - /// When these passes run, VirtRegMap contains legal physreg assignments for - /// all virtual registers. - virtual bool addPreRewrite() { - return false; - } - - /// This method may be implemented by targets that want to run passes after - /// register allocation pass pipeline but before prolog-epilog insertion. - virtual void addPostRegAlloc() { } - - /// Add passes that optimize machine instructions after register allocation. - virtual void addMachineLateOptimization(); - - /// This method may be implemented by targets that want to run passes after - /// prolog-epilog insertion and before the second instruction scheduling pass. - virtual void addPreSched2() { } - - /// addGCPasses - Add late codegen passes that analyze code for garbage - /// collection. This should return true if GC info should be printed after - /// these passes. - virtual bool addGCPasses(); - - /// Add standard basic block placement passes. - virtual void addBlockPlacement(); - - /// This pass may be implemented by targets that want to run passes - /// immediately before machine code is emitted. - virtual void addPreEmitPass() { } - - /// Utilities for targets to add passes to the pass manager. - /// - - /// Add a CodeGen pass at this point in the pipeline after checking overrides. - /// Return the pass that was added, or zero if no pass was added. - /// @p printAfter if true and adding a machine function pass add an extra - /// machine printer pass afterwards - /// @p verifyAfter if true and adding a machine function pass add an extra - /// machine verification pass afterwards. - AnalysisID addPass(AnalysisID PassID, bool verifyAfter = true, - bool printAfter = true); - - /// Add a pass to the PassManager if that pass is supposed to be run, as - /// determined by the StartAfter and StopAfter options. Takes ownership of the - /// pass. - /// @p printAfter if true and adding a machine function pass add an extra - /// machine printer pass afterwards - /// @p verifyAfter if true and adding a machine function pass add an extra - /// machine verification pass afterwards. - void addPass(Pass *P, bool verifyAfter = true, bool printAfter = true); - - /// addMachinePasses helper to create the target-selected or overriden - /// regalloc pass. - FunctionPass *createRegAllocPass(bool Optimized); - - /// printAndVerify - Add a pass to dump then verify the machine function, if - /// those steps are enabled. - /// - void printAndVerify(const std::string &Banner); - - /// Add a pass to print the machine function if printing is enabled. - void addPrintPass(const std::string &Banner); - - /// Add a pass to perform basic verification of the machine function if - /// verification is enabled. - void addVerifyPass(const std::string &Banner); -}; -} // namespace llvm +} // End llvm namespace /// List of target independent CodeGen pass IDs. namespace llvm { - FunctionPass *createAtomicExpandPass(const TargetMachine *TM); + FunctionPass *createAtomicExpandPass(); /// createUnreachableBlockEliminationPass - The LLVM code generator does not /// work well with unreachable basic blocks (what live ranges make sense for a @@ -377,6 +43,9 @@ /// the entry block. FunctionPass *createUnreachableBlockEliminationPass(); + /// Insert mcount-like function calls. + FunctionPass *createCountingFunctionInserterPass(); + /// MachineFunctionPrinter pass - This pass prints out the machine function to /// the given stream as a debugging tool. MachineFunctionPass * @@ -387,9 +56,21 @@ /// using the MIR serialization format. MachineFunctionPass *createPrintMIRPass(raw_ostream &OS); + /// This pass resets a MachineFunction when it has the FailedISel property + /// as if it was just created. + /// If EmitFallbackDiag is true, the pass will emit a + /// DiagnosticInfoISelFallback for every MachineFunction it resets. + /// If AbortOnFailedISel is true, abort compilation instead of resetting. + MachineFunctionPass *createResetMachineFunctionPass(bool EmitFallbackDiag, + bool AbortOnFailedISel); + /// createCodeGenPreparePass - Transform the code to expose more pattern /// matching during instruction selection. - FunctionPass *createCodeGenPreparePass(const TargetMachine *TM = nullptr); + FunctionPass *createCodeGenPreparePass(); + + /// createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather + /// and scatter intrinsics with scalar code when target doesn't support them. + FunctionPass *createScalarizeMaskedMemIntrinPass(); /// AtomicExpandID -- Lowers atomic operations in terms of either cmpxchg /// load-linked/store-conditional loops. @@ -404,6 +85,9 @@ /// MachineDominanaceFrontier - This pass is a machine dominators analysis pass. extern char &MachineDominanceFrontierID; + /// MachineRegionInfo - This pass computes SESE regions for machine functions. + extern char &MachineRegionInfoPassID; + /// EdgeBundles analysis - Bundle machine CFG edges. extern char &EdgeBundlesID; @@ -449,6 +133,16 @@ // instruction and update the MachineFunctionInfo with that information. extern char &ShrinkWrapID; + /// LiveRangeShrink pass. Move instruction close to its definition to shrink + /// the definition's live range. + extern char &LiveRangeShrinkID; + + /// Greedy register allocator. + extern char &RAGreedyID; + + /// Basic register allocator. + extern char &RABasicID; + /// VirtRegRewriter pass. Rewrite virtual registers to physical registers as /// assigned in VirtRegMap. extern char &VirtRegRewriterID; @@ -460,6 +154,9 @@ /// DeadMachineInstructionElim - This pass removes dead machine instructions. extern char &DeadMachineInstructionElimID; + /// This pass adds dead/undef flags after analyzing subregister lanes. + extern char &DetectDeadLanesID; + /// FastRegisterAllocation Pass - This pass register allocates as fast as /// possible. It is best suited for debug code where live ranges are short. /// @@ -483,11 +180,16 @@ /// PrologEpilogCodeInserter - This pass inserts prolog and epilog code, /// and eliminates abstract frame references. extern char &PrologEpilogCodeInserterID; + MachineFunctionPass *createPrologEpilogInserterPass(); /// ExpandPostRAPseudos - This pass expands pseudo instructions after /// register allocation. extern char &ExpandPostRAPseudosID; + /// createPostRAHazardRecognizer - This pass runs the post-ra hazard + /// recognizer. + extern char &PostRAHazardRecognizerID; + /// createPostRAScheduler - This pass performs post register allocation /// scheduling. extern char &PostRASchedulerID; @@ -498,6 +200,10 @@ /// branches. extern char &BranchFolderPassID; + /// BranchRelaxation - This pass replaces branches that need to jump further + /// than is supported by a branch instruction. + extern char &BranchRelaxationPassID; + /// MachineFunctionPrinterPass - This pass prints out MachineInstr's. extern char &MachineFunctionPrinterPassID; @@ -528,7 +234,8 @@ /// IfConverter - This pass performs machine code if conversion. extern char &IfConverterID; - FunctionPass *createIfConverter(std::function<bool(const Function &)> Ftor); + FunctionPass *createIfConverter( + std::function<bool(const MachineFunction &)> Ftor); /// MachineBlockPlacement - This pass places basic blocks based on branch /// probabilities. @@ -589,9 +296,19 @@ /// \brief This pass lays out funclets contiguously. extern char &FuncletLayoutID; + /// This pass inserts the XRay instrumentation sleds if they are supported by + /// the target platform. + extern char &XRayInstrumentationID; + + /// This pass inserts FEntry calls + extern char &FEntryInserterID; + + /// \brief This pass implements the "patchable-function" attribute. + extern char &PatchableFunctionID; + /// createStackProtectorPass - This pass adds stack protectors to functions. /// - FunctionPass *createStackProtectorPass(const TargetMachine *TM); + FunctionPass *createStackProtectorPass(); /// createMachineVerifierPass - This pass verifies cenerated machine code /// instructions for correctness. @@ -600,11 +317,11 @@ /// createDwarfEHPass - This pass mulches exception handling code into a form /// adapted to code generation. Required if using dwarf exception handling. - FunctionPass *createDwarfEHPass(const TargetMachine *TM); + FunctionPass *createDwarfEHPass(); /// createWinEHPass - Prepares personality functions used by MSVC on Windows, /// in addition to the Itanium LSDA based personalities. - FunctionPass *createWinEHPass(const TargetMachine *TM); + FunctionPass *createWinEHPass(); /// createSjLjEHPreparePass - This pass adapts exception handling code to use /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow. @@ -620,19 +337,11 @@ /// ExpandISelPseudos - This pass expands pseudo-instructions. extern char &ExpandISelPseudosID; - /// createExecutionDependencyFixPass - This pass fixes execution time - /// problems with dependent instructions, such as switching execution - /// domains to match. - /// - /// The pass will examine instructions using and defining registers in RC. - /// - FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC); - /// UnpackMachineBundles - This pass unpack machine instruction bundles. extern char &UnpackMachineBundlesID; FunctionPass * - createUnpackMachineBundles(std::function<bool(const Function &)> Ftor); + createUnpackMachineBundles(std::function<bool(const MachineFunction &)> Ftor); /// FinalizeMachineBundles - This pass finalize machine instruction /// bundles (created earlier, e.g. during pre-RA scheduling). @@ -656,33 +365,58 @@ /// InterleavedAccess Pass - This pass identifies and matches interleaved /// memory accesses to target specific intrinsics. /// - FunctionPass *createInterleavedAccessPass(const TargetMachine *TM); + FunctionPass *createInterleavedAccessPass(); + + /// LowerEmuTLS - This pass generates __emutls_[vt].xyz variables for all + /// TLS variables for the emulated TLS model. + /// + ModulePass *createLowerEmuTLSPass(); + + /// This pass lowers the @llvm.load.relative intrinsic to instructions. + /// This is unsafe to do earlier because a pass may combine the constant + /// initializer into the load, which may result in an overflowing evaluation. + ModulePass *createPreISelIntrinsicLoweringPass(); + + /// GlobalMerge - This pass merges internal (by default) globals into structs + /// to enable reuse of a base pointer by indexed addressing modes. + /// It can also be configured to focus on size optimizations only. + /// + Pass *createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset, + bool OnlyOptimizeForSize = false, + bool MergeExternalByDefault = false); + + /// This pass splits the stack into a safe stack and an unsafe stack to + /// protect against stack-based overflow vulnerabilities. + FunctionPass *createSafeStackPass(); + + /// This pass detects subregister lanes in a virtual register that are used + /// independently of other lanes and splits them into separate virtual + /// registers. + extern char &RenameIndependentSubregsID; + + /// This pass is executed POST-RA to collect which physical registers are + /// preserved by given machine function. + FunctionPass *createRegUsageInfoCollector(); + + /// Return a MachineFunction pass that identifies call sites + /// and propagates register usage information of callee to caller + /// if available with PysicalRegisterUsageInfo pass. + FunctionPass *createRegUsageInfoPropPass(); + + /// This pass performs software pipelining on machine instructions. + extern char &MachinePipelinerID; + + /// This pass frees the memory occupied by the MachineFunction. + FunctionPass *createFreeMachineFunctionPass(); + + /// This pass performs outlining on machine instructions directly before + /// printing assembly. + ModulePass *createMachineOutlinerPass(bool OutlineFromLinkOnceODRs = false); + + /// This pass expands the experimental reduction intrinsics into sequences of + /// shuffles. + FunctionPass *createExpandReductionsPass(); + } // End llvm namespace -/// Target machine pass initializer for passes with dependencies. Use with -/// INITIALIZE_TM_PASS_END. -#define INITIALIZE_TM_PASS_BEGIN INITIALIZE_PASS_BEGIN - -/// Target machine pass initializer for passes with dependencies. Use with -/// INITIALIZE_TM_PASS_BEGIN. -#define INITIALIZE_TM_PASS_END(passName, arg, name, cfg, analysis) \ - PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \ - PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis, \ - PassInfo::TargetMachineCtor_t(callTargetMachineCtor< passName >)); \ - Registry.registerPass(*PI, true); \ - return PI; \ - } \ - void llvm::initialize##passName##Pass(PassRegistry &Registry) { \ - CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \ - } - -/// This initializer registers TargetMachine constructor, so the pass being -/// initialized can use target dependent interfaces. Please do not move this -/// macro to be together with INITIALIZE_PASS, which is a complete target -/// independent initializer, and we don't want to make libScalarOpts depend -/// on libCodeGen. -#define INITIALIZE_TM_PASS(passName, arg, name, cfg, analysis) \ - INITIALIZE_TM_PASS_BEGIN(passName, arg, name, cfg, analysis) \ - INITIALIZE_TM_PASS_END(passName, arg, name, cfg, analysis) - #endif
--- a/include/llvm/CodeGen/TargetPassConfig.h Thu Nov 30 18:21:27 2017 +0900 +++ b/include/llvm/CodeGen/TargetPassConfig.h Thu Nov 30 20:04:56 2017 +0900 @@ -158,7 +158,9 @@ void setInitialized() { Initialized = true; } CodeGenOpt::Level getOptLevel() const; - +#ifndef noCbC + unsigned hasCodeSegment() const; +#endif /// Describe the status of the codegen /// pipeline set by this target pass config. /// Having a limited codegen pipeline means that options
--- a/include/llvm/IR/Type.h Thu Nov 30 18:21:27 2017 +0900 +++ b/include/llvm/IR/Type.h Thu Nov 30 20:04:56 2017 +0900 @@ -1,4 +1,4 @@ -//===-- llvm/Type.h - Classes for handling data types -----------*- C++ -*-===// +//===- llvm/Type.h - Classes for handling data types ------------*- C++ -*-===// // // The LLVM Compiler Infrastructure // @@ -16,22 +16,24 @@ #define LLVM_IR_TYPE_H #include "llvm/ADT/APFloat.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallPtrSet.h" #include "llvm/Support/CBindingWrapping.h" #include "llvm/Support/Casting.h" -#include "llvm/Support/DataTypes.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/ErrorHandling.h" +#include <cassert> +#include <cstdint> +#include <iterator> namespace llvm { +template<class GraphType> struct GraphTraits; +class IntegerType; +class LLVMContext; class PointerType; -class IntegerType; class raw_ostream; -class Module; -class LLVMContext; -class LLVMContextImpl; class StringRef; -template<class GraphType> struct GraphTraits; /// The instances of the Type class are immutable: once they are created, /// they are never changed. Also note that only one instance of a particular @@ -73,22 +75,24 @@ PointerTyID, ///< 15: Pointers VectorTyID ///< 16: SIMD 'packed' format, or other vector type #ifndef noCbC - ,__CodeTyID + ,__CodeTyID ///< 17: CbC Code Segment type #endif }; private: - /// Context - This refers to the LLVMContext in which this type was uniqued. + /// This refers to the LLVMContext in which this type was uniqued. LLVMContext &Context; TypeID ID : 8; // The current base type of this type. unsigned SubclassData : 24; // Space for subclasses to store data. + // Note that this should be synchronized with + // MAX_INT_BITS value in IntegerType class. protected: friend class LLVMContextImpl; + explicit Type(LLVMContext &C, TypeID tid) - : Context(C), ID(tid), SubclassData(0), - NumContainedTys(0), ContainedTys(nullptr) {} + : Context(C), ID(tid), SubclassData(0) {} ~Type() = default; unsigned getSubclassData() const { return SubclassData; } @@ -99,65 +103,71 @@ assert(getSubclassData() == val && "Subclass data too large for field"); } - /// NumContainedTys - Keeps track of how many Type*'s there are in the - /// ContainedTys list. - unsigned NumContainedTys; + /// Keeps track of how many Type*'s there are in the ContainedTys list. + unsigned NumContainedTys = 0; - /// ContainedTys - A pointer to the array of Types contained by this Type. - /// For example, this includes the arguments of a function type, the elements - /// of a structure, the pointee of a pointer, the element type of an array, - /// etc. This pointer may be 0 for types that don't contain other types - /// (Integer, Double, Float). - Type * const *ContainedTys; + /// A pointer to the array of Types contained by this Type. For example, this + /// includes the arguments of a function type, the elements of a structure, + /// the pointee of a pointer, the element type of an array, etc. This pointer + /// may be 0 for types that don't contain other types (Integer, Double, + /// Float). + Type * const *ContainedTys = nullptr; + + static bool isSequentialType(TypeID TyID) { + return TyID == ArrayTyID || TyID == VectorTyID; + } public: - void print(raw_ostream &O, bool IsForDebug = false) const; + /// Print the current type. + /// Omit the type details if \p NoDetails == true. + /// E.g., let %st = type { i32, i16 } + /// When \p NoDetails is true, we only print %st. + /// Put differently, \p NoDetails prints the type as if + /// inlined with the operands when printing an instruction. + void print(raw_ostream &O, bool IsForDebug = false, + bool NoDetails = false) const; + void dump() const; - /// getContext - Return the LLVMContext in which this type was uniqued. + /// Return the LLVMContext in which this type was uniqued. LLVMContext &getContext() const { return Context; } //===--------------------------------------------------------------------===// // Accessors for working with types. // - /// getTypeID - Return the type id for the type. This will return one - /// of the TypeID enum elements defined above. - /// + /// Return the type id for the type. This will return one of the TypeID enum + /// elements defined above. TypeID getTypeID() const { return ID; } - /// isVoidTy - Return true if this is 'void'. #ifndef noCbC bool isVoidTy() const { return (getTypeID() == VoidTyID || getTypeID() == __CodeTyID); } + /// is__CodeTy - Return true if this is '__code'. + bool is__CodeTy() const { return getTypeID() == __CodeTyID; } #else + /// Return true if this is 'void'. bool isVoidTy() const { return getTypeID() == VoidTyID; } #endif -#ifndef noCbC - /// is__CodeTy - Return true if this is '__code'. - bool is__CodeTy() const { return getTypeID() == __CodeTyID; } -#endif - - /// isHalfTy - Return true if this is 'half', a 16-bit IEEE fp type. + /// Return true if this is 'half', a 16-bit IEEE fp type. bool isHalfTy() const { return getTypeID() == HalfTyID; } - /// isFloatTy - Return true if this is 'float', a 32-bit IEEE fp type. + /// Return true if this is 'float', a 32-bit IEEE fp type. bool isFloatTy() const { return getTypeID() == FloatTyID; } - /// isDoubleTy - Return true if this is 'double', a 64-bit IEEE fp type. + /// Return true if this is 'double', a 64-bit IEEE fp type. bool isDoubleTy() const { return getTypeID() == DoubleTyID; } - /// isX86_FP80Ty - Return true if this is x86 long double. + /// Return true if this is x86 long double. bool isX86_FP80Ty() const { return getTypeID() == X86_FP80TyID; } - /// isFP128Ty - Return true if this is 'fp128'. + /// Return true if this is 'fp128'. bool isFP128Ty() const { return getTypeID() == FP128TyID; } - /// isPPC_FP128Ty - Return true if this is powerpc long double. + /// Return true if this is powerpc long double. bool isPPC_FP128Ty() const { return getTypeID() == PPC_FP128TyID; } - /// isFloatingPointTy - Return true if this is one of the six floating point - /// types + /// Return true if this is one of the six floating-point types bool isFloatingPointTy() const { return getTypeID() == HalfTyID || getTypeID() == FloatTyID || getTypeID() == DoubleTyID || @@ -167,83 +177,76 @@ const fltSemantics &getFltSemantics() const { switch (getTypeID()) { - case HalfTyID: return APFloat::IEEEhalf; - case FloatTyID: return APFloat::IEEEsingle; - case DoubleTyID: return APFloat::IEEEdouble; - case X86_FP80TyID: return APFloat::x87DoubleExtended; - case FP128TyID: return APFloat::IEEEquad; - case PPC_FP128TyID: return APFloat::PPCDoubleDouble; + case HalfTyID: return APFloat::IEEEhalf(); + case FloatTyID: return APFloat::IEEEsingle(); + case DoubleTyID: return APFloat::IEEEdouble(); + case X86_FP80TyID: return APFloat::x87DoubleExtended(); + case FP128TyID: return APFloat::IEEEquad(); + case PPC_FP128TyID: return APFloat::PPCDoubleDouble(); default: llvm_unreachable("Invalid floating type"); } } - /// isX86_MMXTy - Return true if this is X86 MMX. + /// Return true if this is X86 MMX. bool isX86_MMXTy() const { return getTypeID() == X86_MMXTyID; } - /// isFPOrFPVectorTy - Return true if this is a FP type or a vector of FP. - /// + /// Return true if this is a FP type or a vector of FP. bool isFPOrFPVectorTy() const { return getScalarType()->isFloatingPointTy(); } - /// isLabelTy - Return true if this is 'label'. + /// Return true if this is 'label'. bool isLabelTy() const { return getTypeID() == LabelTyID; } - /// isMetadataTy - Return true if this is 'metadata'. + /// Return true if this is 'metadata'. bool isMetadataTy() const { return getTypeID() == MetadataTyID; } - /// isTokenTy - Return true if this is 'token'. + /// Return true if this is 'token'. bool isTokenTy() const { return getTypeID() == TokenTyID; } - /// isIntegerTy - True if this is an instance of IntegerType. - /// + /// True if this is an instance of IntegerType. bool isIntegerTy() const { return getTypeID() == IntegerTyID; } - /// isIntegerTy - Return true if this is an IntegerType of the given width. + /// Return true if this is an IntegerType of the given width. bool isIntegerTy(unsigned Bitwidth) const; - /// isIntOrIntVectorTy - Return true if this is an integer type or a vector of - /// integer types. - /// + /// Return true if this is an integer type or a vector of integer types. bool isIntOrIntVectorTy() const { return getScalarType()->isIntegerTy(); } - /// isFunctionTy - True if this is an instance of FunctionType. - /// + /// Return true if this is an integer type or a vector of integer types of + /// the given width. + bool isIntOrIntVectorTy(unsigned BitWidth) const { + return getScalarType()->isIntegerTy(BitWidth); + } + + /// True if this is an instance of FunctionType. bool isFunctionTy() const { return getTypeID() == FunctionTyID; } - /// isStructTy - True if this is an instance of StructType. - /// + /// True if this is an instance of StructType. bool isStructTy() const { return getTypeID() == StructTyID; } - /// isArrayTy - True if this is an instance of ArrayType. - /// + /// True if this is an instance of ArrayType. bool isArrayTy() const { return getTypeID() == ArrayTyID; } - /// isPointerTy - True if this is an instance of PointerType. - /// + /// True if this is an instance of PointerType. bool isPointerTy() const { return getTypeID() == PointerTyID; } - /// isPtrOrPtrVectorTy - Return true if this is a pointer type or a vector of - /// pointer types. - /// + /// Return true if this is a pointer type or a vector of pointer types. bool isPtrOrPtrVectorTy() const { return getScalarType()->isPointerTy(); } - /// isVectorTy - True if this is an instance of VectorType. - /// + /// True if this is an instance of VectorType. bool isVectorTy() const { return getTypeID() == VectorTyID; } - /// canLosslesslyBitCastTo - Return true if this type could be converted - /// with a lossless BitCast to type 'Ty'. For example, i8* to i32*. BitCasts - /// are valid for types of the same size only where no re-interpretation of - /// the bits is done. + /// Return true if this type could be converted with a lossless BitCast to + /// type 'Ty'. For example, i8* to i32*. BitCasts are valid for types of the + /// same size only where no re-interpretation of the bits is done. /// @brief Determine if this type could be losslessly bitcast to Ty bool canLosslesslyBitCastTo(Type *Ty) const; - /// isEmptyTy - Return true if this type is empty, that is, it has no - /// elements or all its elements are empty. + /// Return true if this type is empty, that is, it has no elements or all of + /// its elements are empty. bool isEmptyTy() const; - /// isFirstClassType - Return true if the type is "first class", meaning it - /// is a valid type for a Value. - /// + /// Return true if the type is "first class", meaning it is a valid type for a + /// Value. bool isFirstClassType() const { #ifndef noCbC return getTypeID() != FunctionTyID && getTypeID() != VoidTyID && getTypeID() != __CodeTyID; @@ -252,28 +255,23 @@ #endif } - /// isSingleValueType - Return true if the type is a valid type for a - /// register in codegen. This includes all first-class types except struct - /// and array types. - /// + /// Return true if the type is a valid type for a register in codegen. This + /// includes all first-class types except struct and array types. bool isSingleValueType() const { return isFloatingPointTy() || isX86_MMXTy() || isIntegerTy() || isPointerTy() || isVectorTy(); } - /// isAggregateType - Return true if the type is an aggregate type. This - /// means it is valid as the first operand of an insertvalue or - /// extractvalue instruction. This includes struct and array types, but - /// does not include vector types. - /// + /// Return true if the type is an aggregate type. This means it is valid as + /// the first operand of an insertvalue or extractvalue instruction. This + /// includes struct and array types, but does not include vector types. bool isAggregateType() const { return getTypeID() == StructTyID || getTypeID() == ArrayTyID; } - /// isSized - Return true if it makes sense to take the size of this type. To - /// get the actual size for a particular target, it is reasonable to use the + /// Return true if it makes sense to take the size of this type. To get the + /// actual size for a particular target, it is reasonable to use the /// DataLayout subsystem to do this. - /// bool isSized(SmallPtrSetImpl<Type*> *Visited = nullptr) const { // If it's a primitive, it is always sized. if (getTypeID() == IntegerTyID || isFloatingPointTy() || @@ -289,8 +287,8 @@ return isSizedDerivedType(Visited); } - /// getPrimitiveSizeInBits - Return the basic size of this type if it is a - /// primitive type. These are fixed by LLVM and are not target dependent. + /// Return the basic size of this type if it is a primitive type. These are + /// fixed by LLVM and are not target-dependent. /// This will return zero if the type does not have a size or is not a /// primitive type. /// @@ -301,31 +299,37 @@ /// unsigned getPrimitiveSizeInBits() const LLVM_READONLY; - /// getScalarSizeInBits - If this is a vector type, return the - /// getPrimitiveSizeInBits value for the element type. Otherwise return the - /// getPrimitiveSizeInBits value for this type. + /// If this is a vector type, return the getPrimitiveSizeInBits value for the + /// element type. Otherwise return the getPrimitiveSizeInBits value for this + /// type. unsigned getScalarSizeInBits() const LLVM_READONLY; - /// getFPMantissaWidth - Return the width of the mantissa of this type. This - /// is only valid on floating point types. If the FP type does not - /// have a stable mantissa (e.g. ppc long double), this method returns -1. + /// Return the width of the mantissa of this type. This is only valid on + /// floating-point types. If the FP type does not have a stable mantissa (e.g. + /// ppc long double), this method returns -1. int getFPMantissaWidth() const; - /// getScalarType - If this is a vector type, return the element type, - /// otherwise return 'this'. - Type *getScalarType() const LLVM_READONLY; + /// If this is a vector type, return the element type, otherwise return + /// 'this'. + Type *getScalarType() const { + if (isVectorTy()) + return getVectorElementType(); + return const_cast<Type*>(this); + } //===--------------------------------------------------------------------===// // Type Iteration support. // - typedef Type * const *subtype_iterator; + using subtype_iterator = Type * const *; + subtype_iterator subtype_begin() const { return ContainedTys; } subtype_iterator subtype_end() const { return &ContainedTys[NumContainedTys];} ArrayRef<Type*> subtypes() const { return makeArrayRef(subtype_begin(), subtype_end()); } - typedef std::reverse_iterator<subtype_iterator> subtype_reverse_iterator; + using subtype_reverse_iterator = std::reverse_iterator<subtype_iterator>; + subtype_reverse_iterator subtype_rbegin() const { return subtype_reverse_iterator(subtype_end()); } @@ -333,17 +337,15 @@ return subtype_reverse_iterator(subtype_begin()); } - /// getContainedType - This method is used to implement the type iterator - /// (defined at the end of the file). For derived types, this returns the - /// types 'contained' in the derived type. - /// + /// This method is used to implement the type iterator (defined at the end of + /// the file). For derived types, this returns the types 'contained' in the + /// derived type. Type *getContainedType(unsigned i) const { assert(i < NumContainedTys && "Index out of range!"); return ContainedTys[i]; } - /// getNumContainedTypes - Return the number of types in the derived type. - /// + /// Return the number of types in the derived type. unsigned getNumContainedTypes() const { return NumContainedTys; } //===--------------------------------------------------------------------===// @@ -363,17 +365,30 @@ inline unsigned getStructNumElements() const; inline Type *getStructElementType(unsigned N) const; - inline Type *getSequentialElementType() const; + inline Type *getSequentialElementType() const { + assert(isSequentialType(getTypeID()) && "Not a sequential type!"); + return ContainedTys[0]; + } inline uint64_t getArrayNumElements() const; - Type *getArrayElementType() const { return getSequentialElementType(); } + + Type *getArrayElementType() const { + assert(getTypeID() == ArrayTyID); + return ContainedTys[0]; + } inline unsigned getVectorNumElements() const; - Type *getVectorElementType() const { return getSequentialElementType(); } + Type *getVectorElementType() const { + assert(getTypeID() == VectorTyID); + return ContainedTys[0]; + } - Type *getPointerElementType() const { return getSequentialElementType(); } + Type *getPointerElementType() const { + assert(getTypeID() == PointerTyID); + return ContainedTys[0]; + } - /// \brief Get the address space of this pointer or pointer vector type. + /// Get the address space of this pointer or pointer vector type. inline unsigned getPointerAddressSpace() const; //===--------------------------------------------------------------------===// @@ -381,7 +396,7 @@ // instances of Type. // - /// getPrimitiveType - Return a type based on an identifier. + /// Return a type based on an identifier. static Type *getPrimitiveType(LLVMContext &C, TypeID IDNumber); //===--------------------------------------------------------------------===// @@ -398,6 +413,9 @@ static Type *getPPC_FP128Ty(LLVMContext &C); static Type *getX86_MMXTy(LLVMContext &C); static Type *getTokenTy(LLVMContext &C); +#ifndef noCbC + static Type *get__CodeTy(LLVMContext &C); // for CbC project +#endif static IntegerType *getIntNTy(LLVMContext &C, unsigned N); static IntegerType *getInt1Ty(LLVMContext &C); static IntegerType *getInt8Ty(LLVMContext &C); @@ -406,10 +424,6 @@ static IntegerType *getInt64Ty(LLVMContext &C); static IntegerType *getInt128Ty(LLVMContext &C); -#ifndef noCbC - static Type *get__CodeTy(LLVMContext &C); // for CbC project -#endif - //===--------------------------------------------------------------------===// // Convenience methods for getting pointer types with one of the above builtin // types as pointee. @@ -428,19 +442,19 @@ static PointerType *getInt32PtrTy(LLVMContext &C, unsigned AS = 0); static PointerType *getInt64PtrTy(LLVMContext &C, unsigned AS = 0); - /// getPointerTo - Return a pointer to the current type. This is equivalent - /// to PointerType::get(Foo, AddrSpace). + /// Return a pointer to the current type. This is equivalent to + /// PointerType::get(Foo, AddrSpace). PointerType *getPointerTo(unsigned AddrSpace = 0) const; private: - /// isSizedDerivedType - Derived types like structures and arrays are sized - /// iff all of the members of the type are sized as well. Since asking for - /// their size is relatively uncommon, move this operation out of line. + /// Derived types like structures and arrays are sized iff all of the members + /// of the type are sized as well. Since asking for their size is relatively + /// uncommon, move this operation out-of-line. bool isSizedDerivedType(SmallPtrSetImpl<Type*> *Visited = nullptr) const; }; // Printing of types. -static inline raw_ostream &operator<<(raw_ostream &OS, Type &T) { +inline raw_ostream &operator<<(raw_ostream &OS, const Type &T) { T.print(OS); return OS; } @@ -457,29 +471,21 @@ // graph of sub types. template <> struct GraphTraits<Type *> { - typedef Type NodeType; - typedef Type::subtype_iterator ChildIteratorType; + using NodeRef = Type *; + using ChildIteratorType = Type::subtype_iterator; - static inline NodeType *getEntryNode(Type *T) { return T; } - static inline ChildIteratorType child_begin(NodeType *N) { - return N->subtype_begin(); - } - static inline ChildIteratorType child_end(NodeType *N) { - return N->subtype_end(); - } + static NodeRef getEntryNode(Type *T) { return T; } + static ChildIteratorType child_begin(NodeRef N) { return N->subtype_begin(); } + static ChildIteratorType child_end(NodeRef N) { return N->subtype_end(); } }; template <> struct GraphTraits<const Type*> { - typedef const Type NodeType; - typedef Type::subtype_iterator ChildIteratorType; + using NodeRef = const Type *; + using ChildIteratorType = Type::subtype_iterator; - static inline NodeType *getEntryNode(NodeType *T) { return T; } - static inline ChildIteratorType child_begin(NodeType *N) { - return N->subtype_begin(); - } - static inline ChildIteratorType child_end(NodeType *N) { - return N->subtype_end(); - } + static NodeRef getEntryNode(NodeRef T) { return T; } + static ChildIteratorType child_begin(NodeRef N) { return N->subtype_begin(); } + static ChildIteratorType child_end(NodeRef N) { return N->subtype_end(); } }; // Create wrappers for C Binding types (see CBindingWrapping.h). @@ -495,6 +501,6 @@ return reinterpret_cast<LLVMTypeRef*>(const_cast<Type**>(Tys)); } -} // End llvm namespace +} // end namespace llvm -#endif +#endif // LLVM_IR_TYPE_H
--- a/include/llvm/Target/TargetOptions.h Thu Nov 30 18:21:27 2017 +0900 +++ b/include/llvm/Target/TargetOptions.h Thu Nov 30 20:04:56 2017 +0900 @@ -15,14 +15,11 @@ #ifndef LLVM_TARGET_TARGETOPTIONS_H #define LLVM_TARGET_TARGETOPTIONS_H -#include "llvm/Target/TargetRecip.h" #include "llvm/MC/MCTargetOptions.h" -#include <string> namespace llvm { class MachineFunction; class Module; - class StringRef; namespace FloatABI { enum ABIType { @@ -58,6 +55,15 @@ }; } + namespace FPDenormal { + enum DenormalMode { + IEEE, // IEEE 754 denormal numbers + PreserveSign, // the sign of a flushed-to-zero number is preserved in + // the sign of 0 + PositiveZero // denormals are flushed to positive zero + }; + } + enum class EABI { Unknown, Default, // Default means not specified @@ -93,18 +99,16 @@ class TargetOptions { public: TargetOptions() - : PrintMachineCode(false), LessPreciseFPMADOption(false), - UnsafeFPMath(false), NoInfsFPMath(false), NoNaNsFPMath(false), + : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false), + NoNaNsFPMath(false), NoTrappingFPMath(false), + NoSignedZerosFPMath(false), HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false), - GuaranteedTailCallOpt(false), StackAlignmentOverride(0), - EnableFastISel(false), PositionIndependentExecutable(false), - UseInitArray(false), DisableIntegratedAS(false), - CompressDebugSections(false), FunctionSections(false), - DataSections(false), UniqueSectionNames(true), TrapUnreachable(false), - EmulatedTLS(false), FloatABIType(FloatABI::Default), - AllowFPOpFusion(FPOpFusion::Standard), Reciprocals(TargetRecip()), - JTType(JumpTable::Single), ThreadModel(ThreadModel::POSIX), - EABIVersion(EABI::Default), DebuggerTuning(DebuggerKind::Default) {} + GuaranteedTailCallOpt(false), StackSymbolOrdering(true), + EnableFastISel(false), UseInitArray(false), + DisableIntegratedAS(false), RelaxELFRelocations(false), + FunctionSections(false), DataSections(false), + UniqueSectionNames(true), TrapUnreachable(false), EmulatedTLS(false), + EnableIPRA(false) {} /// PrintMachineCode - This flag is enabled when the -print-machineinstrs /// option is specified on the command line, and should enable debugging @@ -115,20 +119,11 @@ /// optimization should be disabled for the given machine function. bool DisableFramePointerElim(const MachineFunction &MF) const; - /// LessPreciseFPMAD - This flag is enabled when the - /// -enable-fp-mad is specified on the command line. When this flag is off - /// (the default), the code generator is not allowed to generate mad - /// (multiply add) if the result is "less precise" than doing those - /// operations individually. - unsigned LessPreciseFPMADOption : 1; - bool LessPreciseFPMAD() const; - /// UnsafeFPMath - This flag is enabled when the /// -enable-unsafe-fp-math flag is specified on the command line. When /// this flag is off (the default), the code generator is not allowed to /// produce results that are "less precise" than IEEE allows. This includes /// use of X86 instructions like FSIN and FCOS instead of libcalls. - /// UnsafeFPMath implies LessPreciseFPMAD. unsigned UnsafeFPMath : 1; /// NoInfsFPMath - This flag is enabled when the @@ -143,6 +138,17 @@ /// assume the FP arithmetic arguments and results are never NaNs. unsigned NoNaNsFPMath : 1; + /// NoTrappingFPMath - This flag is enabled when the + /// -enable-no-trapping-fp-math is specified on the command line. This + /// specifies that there are no trap handlers to handle exceptions. + unsigned NoTrappingFPMath : 1; + + /// NoSignedZerosFPMath - This flag is enabled when the + /// -enable-no-signed-zeros-fp-math is specified on the command line. This + /// specifies that optimizations are allowed to treat the sign of a zero + /// argument or result as insignificant. + unsigned NoSignedZerosFPMath : 1; + /// HonorSignDependentRoundingFPMath - This returns true when the /// -enable-sign-dependent-rounding-fp-math is specified. If this returns /// false (the default), the code generator is allowed to assume that the @@ -167,19 +173,19 @@ unsigned GuaranteedTailCallOpt : 1; /// StackAlignmentOverride - Override default stack alignment for target. - unsigned StackAlignmentOverride; + unsigned StackAlignmentOverride = 0; + + /// StackSymbolOrdering - When true, this will allow CodeGen to order + /// the local stack symbols (for code size, code locality, or any other + /// heuristics). When false, the local symbols are left in whatever order + /// they were generated. Default is true. + unsigned StackSymbolOrdering : 1; /// EnableFastISel - This flag enables fast-path instruction selection /// which trades away generated code quality in favor of reducing /// compile time. unsigned EnableFastISel : 1; - /// PositionIndependentExecutable - This flag indicates whether the code - /// will eventually be linked into a single executable, despite the PIC - /// relocation model being in use. It's value is undefined (and irrelevant) - /// if the relocation model is anything other than PIC. - unsigned PositionIndependentExecutable : 1; - /// UseInitArray - Use .init_array instead of .ctors for static /// constructors. unsigned UseInitArray : 1; @@ -188,7 +194,9 @@ unsigned DisableIntegratedAS : 1; /// Compress DWARF debug sections. - unsigned CompressDebugSections : 1; + DebugCompressionType CompressDebugSections = DebugCompressionType::None; + + unsigned RelaxELFRelocations : 1; /// Emit functions into separate sections. unsigned FunctionSections : 1; @@ -205,13 +213,16 @@ /// function in the runtime library.. unsigned EmulatedTLS : 1; + /// This flag enables InterProcedural Register Allocation (IPRA). + unsigned EnableIPRA : 1; + /// FloatABIType - This setting is set by -float-abi=xxx option is specfied /// on the command line. This setting may either be Default, Soft, or Hard. /// Default selects the target's default behavior. Soft selects the ABI for /// software floating point, but does not indicate that FP hardware may not /// be used. Such a combination is unfortunately popular (e.g. /// arm-apple-darwin). Hard presumes that the normal FP ABI is used. - FloatABI::ABIType FloatABIType; + FloatABI::ABIType FloatABIType = FloatABI::Default; /// AllowFPOpFusion - This flag is set by the -fuse-fp-ops=xxx option. /// This controls the creation of fused FP ops that store intermediate @@ -229,67 +240,31 @@ /// optimizers. Fused operations that are explicitly specified (e.g. FMA /// via the llvm.fma.* intrinsic) will always be honored, regardless of /// the value of this option. - FPOpFusion::FPOpFusionMode AllowFPOpFusion; + FPOpFusion::FPOpFusionMode AllowFPOpFusion = FPOpFusion::Standard; #ifndef noCbC unsigned HasCodeSegment : 1; #endif - - /// This class encapsulates options for reciprocal-estimate code generation. - TargetRecip Reciprocals; - - /// JTType - This flag specifies the type of jump-instruction table to - /// create for functions that have the jumptable attribute. - JumpTable::JumpTableType JTType; - /// ThreadModel - This flag specifies the type of threading model to assume /// for things like atomics - ThreadModel::Model ThreadModel; + ThreadModel::Model ThreadModel = ThreadModel::POSIX; /// EABIVersion - This flag specifies the EABI version - EABI EABIVersion; + EABI EABIVersion = EABI::Default; /// Which debugger to tune for. - DebuggerKind DebuggerTuning; + DebuggerKind DebuggerTuning = DebuggerKind::Default; + + /// FPDenormalMode - This flags specificies which denormal numbers the code + /// is permitted to require. + FPDenormal::DenormalMode FPDenormalMode = FPDenormal::IEEE; + + /// What exception model to use + ExceptionHandling ExceptionModel = ExceptionHandling::None; /// Machine level options. MCTargetOptions MCOptions; }; -// Comparison operators: - - -inline bool operator==(const TargetOptions &LHS, - const TargetOptions &RHS) { -#define ARE_EQUAL(X) LHS.X == RHS.X - return - ARE_EQUAL(UnsafeFPMath) && - ARE_EQUAL(NoInfsFPMath) && - ARE_EQUAL(NoNaNsFPMath) && - ARE_EQUAL(HonorSignDependentRoundingFPMathOption) && - ARE_EQUAL(NoZerosInBSS) && - ARE_EQUAL(GuaranteedTailCallOpt) && - ARE_EQUAL(StackAlignmentOverride) && - ARE_EQUAL(EnableFastISel) && - ARE_EQUAL(PositionIndependentExecutable) && - ARE_EQUAL(UseInitArray) && - ARE_EQUAL(TrapUnreachable) && - ARE_EQUAL(EmulatedTLS) && - ARE_EQUAL(FloatABIType) && - ARE_EQUAL(AllowFPOpFusion) && - ARE_EQUAL(Reciprocals) && - ARE_EQUAL(JTType) && - ARE_EQUAL(ThreadModel) && - ARE_EQUAL(EABIVersion) && - ARE_EQUAL(DebuggerTuning) && - ARE_EQUAL(MCOptions); -#undef ARE_EQUAL -} - -inline bool operator!=(const TargetOptions &LHS, - const TargetOptions &RHS) { - return !(LHS == RHS); -} - } // End llvm namespace #endif
--- a/lib/CodeGen/TargetPassConfig.cpp Thu Nov 30 18:21:27 2017 +0900 +++ b/lib/CodeGen/TargetPassConfig.cpp Thu Nov 30 20:04:56 2017 +0900 @@ -391,6 +391,12 @@ return TM->getOptLevel(); } +#ifndef noCbC +unsigned TargetPassConfig::hasCodeSegment() const { + return TM->Options.HasCodeSegment; +} +#endif + /// Insert InsertedPassID pass after TargetPassID. void TargetPassConfig::insertPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID,