Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:01

0001 /*===-- llvm-c/DisassemblerTypedefs.h -----------------------------*- C -*-===*\
0002 |*                                                                            *|
0003 |* Part of the LLVM Project, under the Apache License v2.0 with LLVM          *|
0004 |* Exceptions.                                                                *|
0005 |* See https://llvm.org/LICENSE.txt for license information.                  *|
0006 |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception                    *|
0007 |*                                                                            *|
0008 |*===----------------------------------------------------------------------===*/
0009 
0010 #ifndef LLVM_C_DISASSEMBLERTYPES_H
0011 #define LLVM_C_DISASSEMBLERTYPES_H
0012 
0013 #include "llvm-c/DataTypes.h"
0014 #ifdef __cplusplus
0015 #include <cstddef>
0016 #else
0017 #include <stddef.h>
0018 #endif
0019 
0020 /**
0021  * @addtogroup LLVMCDisassembler
0022  *
0023  * @{
0024  */
0025 
0026 /**
0027  * An opaque reference to a disassembler context.
0028  */
0029 typedef void *LLVMDisasmContextRef;
0030 
0031 /**
0032  * The type for the operand information call back function.  This is called to
0033  * get the symbolic information for an operand of an instruction.  Typically
0034  * this is from the relocation information, symbol table, etc.  That block of
0035  * information is saved when the disassembler context is created and passed to
0036  * the call back in the DisInfo parameter.  The instruction containing operand
0037  * is at the PC parameter.  For some instruction sets, there can be more than
0038  * one operand with symbolic information.  To determine the symbolic operand
0039  * information for each operand, the bytes for the specific operand in the
0040  * instruction are specified by the Offset parameter and its byte widith is the
0041  * OpSize parameter.  For instructions sets with fixed widths and one symbolic
0042  * operand per instruction, the Offset parameter will be zero and InstSize
0043  * parameter will be the instruction width.  The information is returned in
0044  * TagBuf and is Triple specific with its specific information defined by the
0045  * value of TagType for that Triple.  If symbolic information is returned the
0046  * function * returns 1, otherwise it returns 0.
0047  */
0048 typedef int (*LLVMOpInfoCallback)(void *DisInfo, uint64_t PC, uint64_t Offset,
0049                                   uint64_t OpSize, uint64_t InstSize,
0050                                   int TagType, void *TagBuf);
0051 
0052 /**
0053  * The initial support in LLVM MC for the most general form of a relocatable
0054  * expression is "AddSymbol - SubtractSymbol + Offset".  For some Darwin targets
0055  * this full form is encoded in the relocation information so that AddSymbol and
0056  * SubtractSymbol can be link edited independent of each other.  Many other
0057  * platforms only allow a relocatable expression of the form AddSymbol + Offset
0058  * to be encoded.
0059  *
0060  * The LLVMOpInfoCallback() for the TagType value of 1 uses the struct
0061  * LLVMOpInfo1.  The value of the relocatable expression for the operand,
0062  * including any PC adjustment, is passed in to the call back in the Value
0063  * field.  The symbolic information about the operand is returned using all
0064  * the fields of the structure with the Offset of the relocatable expression
0065  * returned in the Value field.  It is possible that some symbols in the
0066  * relocatable expression were assembly temporary symbols, for example
0067  * "Ldata - LpicBase + constant", and only the Values of the symbols without
0068  * symbol names are present in the relocation information.  The VariantKind
0069  * type is one of the Target specific #defines below and is used to print
0070  * operands like "_foo@GOT", ":lower16:_foo", etc.
0071  */
0072 struct LLVMOpInfoSymbol1 {
0073   uint64_t Present;  /* 1 if this symbol is present */
0074   const char *Name;  /* symbol name if not NULL */
0075   uint64_t Value;    /* symbol value if name is NULL */
0076 };
0077 
0078 struct LLVMOpInfo1 {
0079   struct LLVMOpInfoSymbol1 AddSymbol;
0080   struct LLVMOpInfoSymbol1 SubtractSymbol;
0081   uint64_t Value;
0082   uint64_t VariantKind;
0083 };
0084 
0085 /**
0086  * The operand VariantKinds for symbolic disassembly.
0087  */
0088 #define LLVMDisassembler_VariantKind_None 0 /* all targets */
0089 
0090 /**
0091  * The ARM target VariantKinds.
0092  */
0093 #define LLVMDisassembler_VariantKind_ARM_HI16 1 /* :upper16: */
0094 #define LLVMDisassembler_VariantKind_ARM_LO16 2 /* :lower16: */
0095 
0096 /**
0097  * The ARM64 target VariantKinds.
0098  */
0099 #define LLVMDisassembler_VariantKind_ARM64_PAGE       1 /* @page */
0100 #define LLVMDisassembler_VariantKind_ARM64_PAGEOFF    2 /* @pageoff */
0101 #define LLVMDisassembler_VariantKind_ARM64_GOTPAGE    3 /* @gotpage */
0102 #define LLVMDisassembler_VariantKind_ARM64_GOTPAGEOFF 4 /* @gotpageoff */
0103 #define LLVMDisassembler_VariantKind_ARM64_TLVP       5 /* @tvlppage */
0104 #define LLVMDisassembler_VariantKind_ARM64_TLVOFF     6 /* @tvlppageoff */
0105 
0106 /**
0107  * The type for the symbol lookup function.  This may be called by the
0108  * disassembler for things like adding a comment for a PC plus a constant
0109  * offset load instruction to use a symbol name instead of a load address value.
0110  * It is passed the block information is saved when the disassembler context is
0111  * created and the ReferenceValue to look up as a symbol.  If no symbol is found
0112  * for the ReferenceValue NULL is returned.  The ReferenceType of the
0113  * instruction is passed indirectly as is the PC of the instruction in
0114  * ReferencePC.  If the output reference can be determined its type is returned
0115  * indirectly in ReferenceType along with ReferenceName if any, or that is set
0116  * to NULL.
0117  */
0118 typedef const char *(*LLVMSymbolLookupCallback)(void *DisInfo,
0119                                                 uint64_t ReferenceValue,
0120                                                 uint64_t *ReferenceType,
0121                                                 uint64_t ReferencePC,
0122                                                 const char **ReferenceName);
0123 /**
0124  * The reference types on input and output.
0125  */
0126 /* No input reference type or no output reference type. */
0127 #define LLVMDisassembler_ReferenceType_InOut_None 0
0128 
0129 /* The input reference is from a branch instruction. */
0130 #define LLVMDisassembler_ReferenceType_In_Branch 1
0131 /* The input reference is from a PC relative load instruction. */
0132 #define LLVMDisassembler_ReferenceType_In_PCrel_Load 2
0133 
0134 /* The input reference is from an ARM64::ADRP instruction. */
0135 #define LLVMDisassembler_ReferenceType_In_ARM64_ADRP 0x100000001
0136 /* The input reference is from an ARM64::ADDXri instruction. */
0137 #define LLVMDisassembler_ReferenceType_In_ARM64_ADDXri 0x100000002
0138 /* The input reference is from an ARM64::LDRXui instruction. */
0139 #define LLVMDisassembler_ReferenceType_In_ARM64_LDRXui 0x100000003
0140 /* The input reference is from an ARM64::LDRXl instruction. */
0141 #define LLVMDisassembler_ReferenceType_In_ARM64_LDRXl 0x100000004
0142 /* The input reference is from an ARM64::ADR instruction. */
0143 #define LLVMDisassembler_ReferenceType_In_ARM64_ADR 0x100000005
0144 
0145 /* The output reference is to as symbol stub. */
0146 #define LLVMDisassembler_ReferenceType_Out_SymbolStub 1
0147 /* The output reference is to a symbol address in a literal pool. */
0148 #define LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr 2
0149 /* The output reference is to a cstring address in a literal pool. */
0150 #define LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr 3
0151 
0152 /* The output reference is to a Objective-C CoreFoundation string. */
0153 #define LLVMDisassembler_ReferenceType_Out_Objc_CFString_Ref 4
0154 /* The output reference is to a Objective-C message. */
0155 #define LLVMDisassembler_ReferenceType_Out_Objc_Message 5
0156 /* The output reference is to a Objective-C message ref. */
0157 #define LLVMDisassembler_ReferenceType_Out_Objc_Message_Ref 6
0158 /* The output reference is to a Objective-C selector ref. */
0159 #define LLVMDisassembler_ReferenceType_Out_Objc_Selector_Ref 7
0160 /* The output reference is to a Objective-C class ref. */
0161 #define LLVMDisassembler_ReferenceType_Out_Objc_Class_Ref 8
0162 
0163 /* The output reference is to a C++ symbol name. */
0164 #define LLVMDisassembler_ReferenceType_DeMangled_Name 9
0165 
0166 /**
0167  * @}
0168  */
0169 
0170 #endif