LLVM  16.0.0git
CodeGen.h
Go to the documentation of this file.
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
23  }
24 
25  // Code model types.
26  namespace CodeModel {
27  // Sync changes with CodeGenCWrappers.h.
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 {
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.
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.
83  // Only zeros call-used GPRs used in the fn.
85  // Only zeros call-used regs used in the fn and pass args.
87  // Only zeros call-used regs used in the fn.
88  Used = ONLY_USED,
89  // Zeros all call-used GPRs that pass args.
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
llvm::PIELevel::Small
@ Small
Definition: CodeGen.h:37
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::PICLevel::SmallPIC
@ SmallPIC
Definition: CodeGen.h:33
llvm::CGFT_ObjectFile
@ CGFT_ObjectFile
Definition: CodeGen.h:65
llvm::TLSModel::GeneralDynamic
@ GeneralDynamic
Definition: CodeGen.h:43
llvm::CodeModel::Medium
@ Medium
Definition: CodeGen.h:28
llvm::UWTableKind::None
@ None
No unwind table requested.
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Skip
@ Skip
llvm::CGFT_Null
@ CGFT_Null
Definition: CodeGen.h:66
llvm::UWTableKind::Default
@ Default
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::Used
@ Used
llvm::Reloc::ROPI_RWPI
@ ROPI_RWPI
Definition: CodeGen.h:22
llvm::CodeModel::Kernel
@ Kernel
Definition: CodeGen.h:28
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind
ZeroCallUsedRegsKind
Definition: CodeGen.h:78
llvm::Reloc::Model
Model
Definition: CodeGen.h:22
llvm::UWTableKind
UWTableKind
Definition: CodeGen.h:100
llvm::MSP430Attrs::CodeModel
CodeModel
Definition: MSP430Attributes.h:37
llvm::FunctionReturnThunksKind::Extern
@ Extern
Replace returns with jump to thunk, don't emit thunk.
llvm::ZeroCallUsedRegs::ONLY_USED
const unsigned ONLY_USED
Definition: CodeGen.h:74
int
Clang compiles this i1 i64 store i64 i64 store i64 i64 store i64 i64 store i64 align Which gets codegen d xmm0 movaps rbp movaps rbp movaps rbp movaps rbp rbp rbp rbp rbp It would be better to have movq s of instead of the movaps s LLVM produces ret int
Definition: README.txt:536
llvm::CodeModel::Small
@ Small
Definition: CodeGen.h:28
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::AllArg
@ AllArg
llvm::CodeModel::Model
Model
Definition: CodeGen.h:28
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::UsedArg
@ UsedArg
llvm::CodeGenOpt::Default
@ Default
Definition: CodeGen.h:55
llvm::TLSModel::LocalDynamic
@ LocalDynamic
Definition: CodeGen.h:44
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::AllGPR
@ AllGPR
llvm::PICLevel::NotPIC
@ NotPIC
Definition: CodeGen.h:33
llvm::FramePointerKind::All
@ All
llvm::FramePointerKind
FramePointerKind
Definition: CodeGen.h:70
llvm::Reloc::ROPI
@ ROPI
Definition: CodeGen.h:22
llvm::CodeGenOpt::Aggressive
@ Aggressive
Definition: CodeGen.h:56
llvm::Reloc::DynamicNoPIC
@ DynamicNoPIC
Definition: CodeGen.h:22
llvm::CodeGenOpt::None
@ None
Definition: CodeGen.h:53
llvm::Reloc::RWPI
@ RWPI
Definition: CodeGen.h:22
llvm::FunctionReturnThunksKind::Invalid
@ Invalid
Not used.
llvm::Reloc::PIC_
@ PIC_
Definition: CodeGen.h:22
llvm::PIELevel::Default
@ Default
Definition: CodeGen.h:37
llvm::CodeGenFileType
CodeGenFileType
These enums are meant to be passed into addPassesToEmitFile to indicate what type of file to emit,...
Definition: CodeGen.h:63
llvm::Reloc::Static
@ Static
Definition: CodeGen.h:22
llvm::UWTableKind::Sync
@ Sync
"Synchronous" unwind tables
llvm::ZeroCallUsedRegs::ONLY_ARG
const unsigned ONLY_ARG
Definition: CodeGen.h:76
llvm::PICLevel::Level
Level
Definition: CodeGen.h:33
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::CodeModel::Tiny
@ Tiny
Definition: CodeGen.h:28
llvm::FunctionReturnThunksKind
FunctionReturnThunksKind
Definition: CodeGen.h:107
llvm::ZeroCallUsedRegs::ONLY_GPR
const unsigned ONLY_GPR
Definition: CodeGen.h:75
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::All
@ All
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::AllGPRArg
@ AllGPRArg
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::UsedGPR
@ UsedGPR
llvm::FramePointerKind::NonLeaf
@ NonLeaf
llvm::PIELevel::Large
@ Large
Definition: CodeGen.h:37
llvm::TLSModel::Model
Model
Definition: CodeGen.h:42
llvm::FunctionReturnThunksKind::Keep
@ Keep
No function return thunk.
llvm::ZeroCallUsedRegs::ZeroCallUsedRegsKind::UsedGPRArg
@ UsedGPRArg
llvm::TLSModel::InitialExec
@ InitialExec
Definition: CodeGen.h:45
llvm::CodeModel::Large
@ Large
Definition: CodeGen.h:28
llvm::PIELevel::Level
Level
Definition: CodeGen.h:37
llvm::FramePointerKind::None
@ None
llvm::CGFT_AssemblyFile
@ CGFT_AssemblyFile
Definition: CodeGen.h:64
llvm::CodeGenOpt::Less
@ Less
Definition: CodeGen.h:54
llvm::PICLevel::BigPIC
@ BigPIC
Definition: CodeGen.h:33
llvm::UWTableKind::Async
@ Async
"Asynchronous" unwind tables (instr precise)
llvm::TLSModel::LocalExec
@ LocalExec
Definition: CodeGen.h:46