File indexing completed on 2026-05-10 08:44:35
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef LLVM_SUPPORT_WIN64EH_H
0016 #define LLVM_SUPPORT_WIN64EH_H
0017
0018 #include "llvm/Support/DataTypes.h"
0019 #include "llvm/Support/Endian.h"
0020
0021 namespace llvm {
0022 namespace Win64EH {
0023
0024
0025
0026 enum UnwindOpcodes {
0027
0028
0029
0030 UOP_PushNonVol = 0,
0031 UOP_AllocLarge,
0032 UOP_AllocSmall,
0033 UOP_SetFPReg,
0034 UOP_SaveNonVol,
0035 UOP_SaveNonVolBig,
0036 UOP_Epilog,
0037 UOP_SpareCode,
0038 UOP_SaveXMM128,
0039 UOP_SaveXMM128Big,
0040 UOP_PushMachFrame,
0041
0042
0043 UOP_AllocMedium,
0044 UOP_SaveR19R20X,
0045 UOP_SaveFPLRX,
0046 UOP_SaveFPLR,
0047 UOP_SaveReg,
0048 UOP_SaveRegX,
0049 UOP_SaveRegP,
0050 UOP_SaveRegPX,
0051 UOP_SaveLRPair,
0052 UOP_SaveFReg,
0053 UOP_SaveFRegX,
0054 UOP_SaveFRegP,
0055 UOP_SaveFRegPX,
0056 UOP_SetFP,
0057 UOP_AddFP,
0058 UOP_Nop,
0059 UOP_End,
0060 UOP_SaveNext,
0061 UOP_TrapFrame,
0062 UOP_Context,
0063 UOP_ECContext,
0064 UOP_ClearUnwoundToCall,
0065 UOP_PACSignLR,
0066 UOP_SaveAnyRegI,
0067 UOP_SaveAnyRegIP,
0068 UOP_SaveAnyRegD,
0069 UOP_SaveAnyRegDP,
0070 UOP_SaveAnyRegQ,
0071 UOP_SaveAnyRegQP,
0072 UOP_SaveAnyRegIX,
0073 UOP_SaveAnyRegIPX,
0074 UOP_SaveAnyRegDX,
0075 UOP_SaveAnyRegDPX,
0076 UOP_SaveAnyRegQX,
0077 UOP_SaveAnyRegQPX,
0078
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088 UOP_AllocHuge,
0089 UOP_WideAllocMedium,
0090 UOP_WideAllocLarge,
0091 UOP_WideAllocHuge,
0092
0093 UOP_WideSaveRegMask,
0094 UOP_SaveSP,
0095 UOP_SaveRegsR4R7LR,
0096 UOP_WideSaveRegsR4R11LR,
0097 UOP_SaveFRegD8D15,
0098 UOP_SaveRegMask,
0099 UOP_SaveLR,
0100 UOP_SaveFRegD0D15,
0101 UOP_SaveFRegD16D31,
0102
0103 UOP_WideNop,
0104
0105 UOP_EndNop,
0106 UOP_WideEndNop,
0107
0108
0109 UOP_Custom,
0110 };
0111
0112
0113
0114 union UnwindCode {
0115 struct {
0116 uint8_t CodeOffset;
0117 uint8_t UnwindOpAndOpInfo;
0118 } u;
0119 support::ulittle16_t FrameOffset;
0120
0121 uint8_t getUnwindOp() const {
0122 return u.UnwindOpAndOpInfo & 0x0F;
0123 }
0124 uint8_t getOpInfo() const {
0125 return (u.UnwindOpAndOpInfo >> 4) & 0x0F;
0126 }
0127
0128 uint32_t getEpilogOffset() const {
0129 assert(getUnwindOp() == UOP_Epilog);
0130 return (getOpInfo() << 8) | static_cast<uint32_t>(u.CodeOffset);
0131 }
0132 };
0133
0134 enum {
0135
0136
0137 UNW_ExceptionHandler = 0x01,
0138
0139
0140 UNW_TerminateHandler = 0x02,
0141
0142
0143 UNW_ChainInfo = 0x04
0144 };
0145
0146
0147 struct RuntimeFunction {
0148 support::ulittle32_t StartAddress;
0149 support::ulittle32_t EndAddress;
0150 support::ulittle32_t UnwindInfoOffset;
0151 };
0152
0153
0154 struct UnwindInfo {
0155 uint8_t VersionAndFlags;
0156 uint8_t PrologSize;
0157 uint8_t NumCodes;
0158 uint8_t FrameRegisterAndOffset;
0159 UnwindCode UnwindCodes[1];
0160
0161 uint8_t getVersion() const {
0162 return VersionAndFlags & 0x07;
0163 }
0164 uint8_t getFlags() const {
0165 return (VersionAndFlags >> 3) & 0x1f;
0166 }
0167 uint8_t getFrameRegister() const {
0168 return FrameRegisterAndOffset & 0x0f;
0169 }
0170 uint8_t getFrameOffset() const {
0171 return (FrameRegisterAndOffset >> 4) & 0x0f;
0172 }
0173
0174
0175
0176
0177
0178
0179
0180
0181
0182
0183 void *getLanguageSpecificData() {
0184 return reinterpret_cast<void *>(&UnwindCodes[(NumCodes+1) & ~1]);
0185 }
0186
0187
0188 const void *getLanguageSpecificData() const {
0189 return reinterpret_cast<const void *>(&UnwindCodes[(NumCodes + 1) & ~1]);
0190 }
0191
0192
0193 uint32_t getLanguageSpecificHandlerOffset() const {
0194 return *reinterpret_cast<const support::ulittle32_t *>(
0195 getLanguageSpecificData());
0196 }
0197
0198
0199 void setLanguageSpecificHandlerOffset(uint32_t offset) {
0200 *reinterpret_cast<support::ulittle32_t *>(getLanguageSpecificData()) =
0201 offset;
0202 }
0203
0204
0205 void *getExceptionData() {
0206 return reinterpret_cast<void *>(reinterpret_cast<uint32_t *>(
0207 getLanguageSpecificData())+1);
0208 }
0209
0210
0211 RuntimeFunction *getChainedFunctionEntry() {
0212 return reinterpret_cast<RuntimeFunction *>(getLanguageSpecificData());
0213 }
0214
0215
0216 const RuntimeFunction *getChainedFunctionEntry() const {
0217 return reinterpret_cast<const RuntimeFunction *>(getLanguageSpecificData());
0218 }
0219 };
0220
0221
0222 }
0223 }
0224
0225 #endif