1 //===-- llvm/Support/CodeGen.h - CodeGen Concepts ---------------*- C++ -*-===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This file define some types which define code generation concepts. For 10 // example, relocation model. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef LLVM_SUPPORT_CODEGEN_H 15 #define LLVM_SUPPORT_CODEGEN_H 16 17 namespace llvm { 18 19 // Relocation model types. 20 namespace Reloc { 21 // Cannot be named PIC due to collision with -DPIC 22 enum Model { Static, PIC_, DynamicNoPIC, ROPI, RWPI, ROPI_RWPI }; 23 } 24 25 // Code model types. 26 namespace CodeModel { 27 // Sync changes with CodeGenCWrappers.h. 28 enum Model { Tiny, Small, Kernel, Medium, Large }; 29 } 30 31 namespace PICLevel { 32 // This is used to map -fpic/-fPIC. 33 enum Level { NotPIC=0, SmallPIC=1, BigPIC=2 }; 34 } 35 36 namespace PIELevel { 37 enum Level { Default=0, Small=1, Large=2 }; 38 } 39 40 // TLS models. 41 namespace TLSModel { 42 enum Model { 43 GeneralDynamic, 44 LocalDynamic, 45 InitialExec, 46 LocalExec 47 }; 48 } 49 50 // Code generation optimization level. 51 namespace CodeGenOpt { 52 enum Level { 53 None = 0, // -O0 54 Less = 1, // -O1 55 Default = 2, // -O2, -Os 56 Aggressive = 3 // -O3 57 }; 58 } 59 60 /// These enums are meant to be passed into addPassesToEmitFile to indicate 61 /// what type of file to emit, and returned by it to indicate what type of 62 /// file could actually be made. 63 enum CodeGenFileType { 64 CGFT_AssemblyFile, 65 CGFT_ObjectFile, 66 CGFT_Null // Do not emit any output. 67 }; 68 69 // Specify what functions should keep the frame pointer. 70 enum class FramePointerKind { None, NonLeaf, All }; 71 72 // Specify what type of zeroing callee-used registers. 73 namespace ZeroCallUsedRegs { 74 const unsigned ONLY_USED = 1U << 1; 75 const unsigned ONLY_GPR = 1U << 2; 76 const unsigned ONLY_ARG = 1U << 3; 77 78 enum class ZeroCallUsedRegsKind : unsigned int { 79 // Don't zero any call-used regs. 80 Skip = 1U << 0, 81 // Only zeros call-used GPRs used in the fn and pass args. 82 UsedGPRArg = ONLY_USED | ONLY_GPR | ONLY_ARG, 83 // Only zeros call-used GPRs used in the fn. 84 UsedGPR = ONLY_USED | ONLY_GPR, 85 // Only zeros call-used regs used in the fn and pass args. 86 UsedArg = ONLY_USED | ONLY_ARG, 87 // Only zeros call-used regs used in the fn. 88 Used = ONLY_USED, 89 // Zeros all call-used GPRs that pass args. 90 AllGPRArg = ONLY_GPR | ONLY_ARG, 91 // Zeros all call-used GPRs. 92 AllGPR = ONLY_GPR, 93 // Zeros all call-used regs that pass args. 94 AllArg = ONLY_ARG, 95 // Zeros all call-used regs. 96 All = 0, 97 }; 98 } // namespace ZeroCallUsedRegs 99 100 enum class UWTableKind { 101 None = 0, ///< No unwind table requested 102 Sync = 1, ///< "Synchronous" unwind tables 103 Async = 2, ///< "Asynchronous" unwind tables (instr precise) 104 Default = 2, 105 }; 106 107 enum class FunctionReturnThunksKind : unsigned int { 108 Keep = 0, ///< No function return thunk. 109 Extern = 1, ///< Replace returns with jump to thunk, don't emit thunk. 110 Invalid = 2, ///< Not used. 111 }; 112 113 } // namespace llvm 114 115 #endif 116