Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:28

0001 //===-- llvm/Support/CodeGen.h - CodeGen Concepts ---------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file define some types which define code generation concepts. For
0010 // example, relocation model.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_SUPPORT_CODEGEN_H
0015 #define LLVM_SUPPORT_CODEGEN_H
0016 
0017 #include <cstdint>
0018 #include <optional>
0019 
0020 namespace llvm {
0021 
0022   // Relocation model types.
0023   namespace Reloc {
0024     // Cannot be named PIC due to collision with -DPIC
0025     enum Model { Static, PIC_, DynamicNoPIC, ROPI, RWPI, ROPI_RWPI };
0026   }
0027 
0028   // Code model types.
0029   namespace CodeModel {
0030     // Sync changes with CodeGenCWrappers.h.
0031     enum Model { Tiny, Small, Kernel, Medium, Large };
0032   }
0033 
0034   namespace PICLevel {
0035     // This is used to map -fpic/-fPIC.
0036     enum Level { NotPIC=0, SmallPIC=1, BigPIC=2 };
0037   }
0038 
0039   namespace PIELevel {
0040     enum Level { Default=0, Small=1, Large=2 };
0041   }
0042 
0043   // TLS models.
0044   namespace TLSModel {
0045     enum Model {
0046       GeneralDynamic,
0047       LocalDynamic,
0048       InitialExec,
0049       LocalExec
0050     };
0051   }
0052 
0053   /// Code generation optimization level.
0054   enum class CodeGenOptLevel {
0055     None = 0,      ///< -O0
0056     Less = 1,      ///< -O1
0057     Default = 2,   ///< -O2, -Os
0058     Aggressive = 3 ///< -O3
0059   };
0060 
0061   namespace CodeGenOpt {
0062   /// Get the \c Level identified by the integer \p OL.
0063   ///
0064   /// Returns std::nullopt if \p OL is invalid.
0065   inline std::optional<CodeGenOptLevel> getLevel(int OL) {
0066     if (OL < 0 || OL > 3)
0067       return std::nullopt;
0068     return static_cast<CodeGenOptLevel>(OL);
0069   }
0070   /// Parse \p C as a single digit integer and get matching \c CodeGenLevel.
0071   ///
0072   /// Returns std::nullopt if the input is not a valid optimization level.
0073   inline std::optional<CodeGenOptLevel> parseLevel(char C) {
0074     if (C < '0')
0075       return std::nullopt;
0076     return getLevel(static_cast<int>(C - '0'));
0077   }
0078   } // namespace CodeGenOpt
0079 
0080   /// These enums are meant to be passed into addPassesToEmitFile to indicate
0081   /// what type of file to emit, and returned by it to indicate what type of
0082   /// file could actually be made.
0083   enum class CodeGenFileType {
0084     AssemblyFile,
0085     ObjectFile,
0086     Null // Do not emit any output.
0087   };
0088 
0089   // Specify what functions should keep the frame pointer.
0090   enum class FramePointerKind { None, NonLeaf, All, Reserved };
0091 
0092   // Specify what type of zeroing callee-used registers.
0093   namespace ZeroCallUsedRegs {
0094   const unsigned ONLY_USED = 1U << 1;
0095   const unsigned ONLY_GPR = 1U << 2;
0096   const unsigned ONLY_ARG = 1U << 3;
0097 
0098   enum class ZeroCallUsedRegsKind : unsigned int {
0099     // Don't zero any call-used regs.
0100     Skip = 1U << 0,
0101     // Only zeros call-used GPRs used in the fn and pass args.
0102     UsedGPRArg = ONLY_USED | ONLY_GPR | ONLY_ARG,
0103     // Only zeros call-used GPRs used in the fn.
0104     UsedGPR = ONLY_USED | ONLY_GPR,
0105     // Only zeros call-used regs used in the fn and pass args.
0106     UsedArg = ONLY_USED | ONLY_ARG,
0107     // Only zeros call-used regs used in the fn.
0108     Used = ONLY_USED,
0109     // Zeros all call-used GPRs that pass args.
0110     AllGPRArg = ONLY_GPR | ONLY_ARG,
0111     // Zeros all call-used GPRs.
0112     AllGPR = ONLY_GPR,
0113     // Zeros all call-used regs that pass args.
0114     AllArg = ONLY_ARG,
0115     // Zeros all call-used regs.
0116     All = 0,
0117   };
0118   } // namespace ZeroCallUsedRegs
0119 
0120   enum class UWTableKind {
0121     None = 0,  ///< No unwind table requested
0122     Sync = 1,  ///< "Synchronous" unwind tables
0123     Async = 2, ///< "Asynchronous" unwind tables (instr precise)
0124     Default = 2,
0125   };
0126 
0127   enum class FunctionReturnThunksKind : unsigned int {
0128     Keep = 0,    ///< No function return thunk.
0129     Extern = 1,  ///< Replace returns with jump to thunk, don't emit thunk.
0130     Invalid = 2, ///< Not used.
0131   };
0132 
0133   } // namespace llvm
0134 
0135 #endif