mirror of
				https://github.com/c64scene-ar/llvm-6502.git
				synced 2025-10-31 08:16:47 +00:00 
			
		
		
		
	Merge lib/Target/X86/X86COFF.h into include/llvm/Support/COFF.h,
patch by Michael Spencer! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108342 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
		| @@ -10,12 +10,12 @@ | |||||||
| // This file contains an definitions used in Windows COFF Files. | // This file contains an definitions used in Windows COFF Files. | ||||||
| // | // | ||||||
| // Structures and enums defined within this file where created using | // Structures and enums defined within this file where created using | ||||||
| // information from Microsofts publicly available PE/COFF format document: | // information from Microsoft's publicly available PE/COFF format document: | ||||||
| //  | //  | ||||||
| // Microsoft Portable Executable and Common Object File Format Specification | // Microsoft Portable Executable and Common Object File Format Specification | ||||||
| // Revision 8.1 - February 15, 2008 | // Revision 8.1 - February 15, 2008 | ||||||
| // | // | ||||||
| // As of 5/2/2010, hosted by microsoft at: | // As of 5/2/2010, hosted by Microsoft at: | ||||||
| // http://www.microsoft.com/whdc/system/platform/firmware/pecoff.mspx | // http://www.microsoft.com/whdc/system/platform/firmware/pecoff.mspx | ||||||
| // | // | ||||||
| //===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||||
| @@ -57,7 +57,7 @@ namespace COFF { | |||||||
|     uint8_t  NumberOfAuxSymbols; |     uint8_t  NumberOfAuxSymbols; | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   enum symbol_flags { |   enum SymbolFlags { | ||||||
|     SF_TypeMask = 0x0000FFFF, |     SF_TypeMask = 0x0000FFFF, | ||||||
|     SF_TypeShift = 0, |     SF_TypeShift = 0, | ||||||
|  |  | ||||||
| @@ -67,36 +67,70 @@ namespace COFF { | |||||||
|     SF_WeakReference = 0x01000000 |     SF_WeakReference = 0x01000000 | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   enum symbol_storage_class { |   /// Storage class tells where and what the symbol represents | ||||||
|     IMAGE_SYM_CLASS_END_OF_FUNCTION  = -1, |   enum SymbolStorageClass { | ||||||
|     IMAGE_SYM_CLASS_NULL             = 0, |     IMAGE_SYM_CLASS_END_OF_FUNCTION  = -1,  ///< Physical end of function | ||||||
|     IMAGE_SYM_CLASS_AUTOMATIC        = 1, |     IMAGE_SYM_CLASS_NULL             = 0,   ///< No symbol | ||||||
|     IMAGE_SYM_CLASS_EXTERNAL         = 2, |     IMAGE_SYM_CLASS_AUTOMATIC        = 1,   ///< Stack variable | ||||||
|     IMAGE_SYM_CLASS_STATIC           = 3, |     IMAGE_SYM_CLASS_EXTERNAL         = 2,   ///< External symbol | ||||||
|     IMAGE_SYM_CLASS_REGISTER         = 4, |     IMAGE_SYM_CLASS_STATIC           = 3,   ///< Static | ||||||
|     IMAGE_SYM_CLASS_EXTERNAL_DEF     = 5, |     IMAGE_SYM_CLASS_REGISTER         = 4,   ///< Register variable | ||||||
|     IMAGE_SYM_CLASS_LABEL            = 6, |     IMAGE_SYM_CLASS_EXTERNAL_DEF     = 5,   ///< External definition | ||||||
|     IMAGE_SYM_CLASS_UNDEFINED_LABEL  = 7, |     IMAGE_SYM_CLASS_LABEL            = 6,   ///< Label | ||||||
|     IMAGE_SYM_CLASS_MEMBER_OF_STRUCT = 8, |     IMAGE_SYM_CLASS_UNDEFINED_LABEL  = 7,   ///< Undefined label | ||||||
|     IMAGE_SYM_CLASS_ARGUMENT         = 9, |     IMAGE_SYM_CLASS_MEMBER_OF_STRUCT = 8,   ///< Member of structure | ||||||
|     IMAGE_SYM_CLASS_STRUCT_TAG       = 10, |     IMAGE_SYM_CLASS_ARGUMENT         = 9,   ///< Function argument | ||||||
|     IMAGE_SYM_CLASS_MEMBER_OF_UNION  = 11, |     IMAGE_SYM_CLASS_STRUCT_TAG       = 10,  ///< Structure tag | ||||||
|     IMAGE_SYM_CLASS_UNION_TAG        = 12, |     IMAGE_SYM_CLASS_MEMBER_OF_UNION  = 11,  ///< Member of union | ||||||
|     IMAGE_SYM_CLASS_TYPE_DEFINITION  = 13, |     IMAGE_SYM_CLASS_UNION_TAG        = 12,  ///< Union tag | ||||||
|     IMAGE_SYM_CLASS_UNDEFINED_STATIC = 14, |     IMAGE_SYM_CLASS_TYPE_DEFINITION  = 13,  ///< Type definition | ||||||
|     IMAGE_SYM_CLASS_ENUM_TAG         = 15, |     IMAGE_SYM_CLASS_UNDEFINED_STATIC = 14,  ///< Undefined static | ||||||
|     IMAGE_SYM_CLASS_MEMBER_OF_ENUM   = 16, |     IMAGE_SYM_CLASS_ENUM_TAG         = 15,  ///< Enumeration tag | ||||||
|     IMAGE_SYM_CLASS_REGISTER_PARAM   = 17, |     IMAGE_SYM_CLASS_MEMBER_OF_ENUM   = 16,  ///< Member of enumeration | ||||||
|     IMAGE_SYM_CLASS_BIT_FIELD        = 18, |     IMAGE_SYM_CLASS_REGISTER_PARAM   = 17,  ///< Register parameter | ||||||
|  |     IMAGE_SYM_CLASS_BIT_FIELD        = 18,  ///< Bit field | ||||||
|  |     /// ".bb" or ".eb" - beginning or end of block | ||||||
|     IMAGE_SYM_CLASS_BLOCK            = 100, |     IMAGE_SYM_CLASS_BLOCK            = 100, | ||||||
|  |     /// ".bf" or ".ef" - beginning or end of function | ||||||
|     IMAGE_SYM_CLASS_FUNCTION         = 101, |     IMAGE_SYM_CLASS_FUNCTION         = 101, | ||||||
|     IMAGE_SYM_CLASS_END_OF_STRUCT    = 102, |     IMAGE_SYM_CLASS_END_OF_STRUCT    = 102, ///< End of structure | ||||||
|     IMAGE_SYM_CLASS_FILE             = 103, |     IMAGE_SYM_CLASS_FILE             = 103, ///< File name | ||||||
|  |     /// Line number, reformatted as symbol | ||||||
|     IMAGE_SYM_CLASS_SECTION          = 104, |     IMAGE_SYM_CLASS_SECTION          = 104, | ||||||
|     IMAGE_SYM_CLASS_WEAK_EXTERNAL    = 105, |     IMAGE_SYM_CLASS_WEAK_EXTERNAL    = 105, ///< Duplicate tag | ||||||
|  |     /// External symbol in dmert public lib | ||||||
|     IMAGE_SYM_CLASS_CLR_TOKEN        = 107 |     IMAGE_SYM_CLASS_CLR_TOKEN        = 107 | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|  |   enum SymbolBaseType { | ||||||
|  |     IMAGE_SYM_TYPE_NULL   = 0,  ///< No type information or unknown base type. | ||||||
|  |     IMAGE_SYM_TYPE_VOID   = 1,  ///< Used with void pointers and functions. | ||||||
|  |     IMAGE_SYM_TYPE_CHAR   = 2,  ///< A character (signed byte). | ||||||
|  |     IMAGE_SYM_TYPE_SHORT  = 3,  ///< A 2-byte signed integer. | ||||||
|  |     IMAGE_SYM_TYPE_INT    = 4,  ///< A natural integer type on the target. | ||||||
|  |     IMAGE_SYM_TYPE_LONG   = 5,  ///< A 4-byte signed integer. | ||||||
|  |     IMAGE_SYM_TYPE_FLOAT  = 6,  ///< A 4-byte floating-point number. | ||||||
|  |     IMAGE_SYM_TYPE_DOUBLE = 7,  ///< An 8-byte floating-point number. | ||||||
|  |     IMAGE_SYM_TYPE_STRUCT = 8,  ///< A structure. | ||||||
|  |     IMAGE_SYM_TYPE_UNION  = 9,  ///< An union. | ||||||
|  |     IMAGE_SYM_TYPE_ENUM   = 10, ///< An enumerated type. | ||||||
|  |     IMAGE_SYM_TYPE_MOE    = 11, ///< A member of enumeration (a specific value). | ||||||
|  |     IMAGE_SYM_TYPE_BYTE   = 12, ///< A byte; unsigned 1-byte integer. | ||||||
|  |     IMAGE_SYM_TYPE_WORD   = 13, ///< A word; unsigned 2-byte integer. | ||||||
|  |     IMAGE_SYM_TYPE_UINT   = 14, ///< An unsigned integer of natural size. | ||||||
|  |     IMAGE_SYM_TYPE_DWORD  = 15  ///< An unsigned 4-byte integer. | ||||||
|  |   }; | ||||||
|  |  | ||||||
|  |   enum SymbolComplexType { | ||||||
|  |     IMAGE_SYM_DTYPE_NULL     = 0, ///< No complex type; simple scalar variable.  | ||||||
|  |     IMAGE_SYM_DTYPE_POINTER  = 1, ///< A pointer to base type. | ||||||
|  |     IMAGE_SYM_DTYPE_FUNCTION = 2, ///< A function that returns a base type. | ||||||
|  |     IMAGE_SYM_DTYPE_ARRAY    = 3, ///< An array of base type. | ||||||
|  |      | ||||||
|  |     /// Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT)) | ||||||
|  |     SCT_COMPLEX_TYPE_SHIFT   = 4 | ||||||
|  |   }; | ||||||
|  |  | ||||||
|   struct section { |   struct section { | ||||||
|     char     Name[NameSize]; |     char     Name[NameSize]; | ||||||
|     uint32_t VirtualSize; |     uint32_t VirtualSize; | ||||||
| @@ -110,7 +144,7 @@ namespace COFF { | |||||||
|     uint32_t Characteristics; |     uint32_t Characteristics; | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   enum section_characteristics { |   enum SectionCharacteristics { | ||||||
|     IMAGE_SCN_TYPE_NO_PAD            = 0x00000008, |     IMAGE_SCN_TYPE_NO_PAD            = 0x00000008, | ||||||
|     IMAGE_SCN_CNT_CODE               = 0x00000020, |     IMAGE_SCN_CNT_CODE               = 0x00000020, | ||||||
|     IMAGE_SCN_CNT_INITIALIZED_DATA   = 0x00000040, |     IMAGE_SCN_CNT_INITIALIZED_DATA   = 0x00000040, | ||||||
| @@ -154,7 +188,7 @@ namespace COFF { | |||||||
|     uint16_t Type; |     uint16_t Type; | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|   enum relocation_type_x86 { |   enum RelocationTypeX86 { | ||||||
|     IMAGE_REL_I386_ABSOLUTE = 0x0000, |     IMAGE_REL_I386_ABSOLUTE = 0x0000, | ||||||
|     IMAGE_REL_I386_DIR16    = 0x0001, |     IMAGE_REL_I386_DIR16    = 0x0001, | ||||||
|     IMAGE_REL_I386_REL16    = 0x0002, |     IMAGE_REL_I386_REL16    = 0x0002, | ||||||
|   | |||||||
| @@ -17,7 +17,6 @@ | |||||||
| #include "X86IntelInstPrinter.h" | #include "X86IntelInstPrinter.h" | ||||||
| #include "X86MCInstLower.h" | #include "X86MCInstLower.h" | ||||||
| #include "X86.h" | #include "X86.h" | ||||||
| #include "X86COFF.h" |  | ||||||
| #include "X86COFFMachineModuleInfo.h" | #include "X86COFFMachineModuleInfo.h" | ||||||
| #include "X86MachineFunctionInfo.h" | #include "X86MachineFunctionInfo.h" | ||||||
| #include "X86TargetMachine.h" | #include "X86TargetMachine.h" | ||||||
| @@ -35,6 +34,7 @@ | |||||||
| #include "llvm/CodeGen/MachineJumpTableInfo.h" | #include "llvm/CodeGen/MachineJumpTableInfo.h" | ||||||
| #include "llvm/CodeGen/MachineModuleInfoImpls.h" | #include "llvm/CodeGen/MachineModuleInfoImpls.h" | ||||||
| #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" | #include "llvm/CodeGen/TargetLoweringObjectFileImpl.h" | ||||||
|  | #include "llvm/Support/COFF.h" | ||||||
| #include "llvm/Support/ErrorHandling.h" | #include "llvm/Support/ErrorHandling.h" | ||||||
| #include "llvm/Target/Mangler.h" | #include "llvm/Target/Mangler.h" | ||||||
| #include "llvm/Target/TargetOptions.h" | #include "llvm/Target/TargetOptions.h" | ||||||
| @@ -60,8 +60,10 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) { | |||||||
|   if (Subtarget->isTargetCOFF()) { |   if (Subtarget->isTargetCOFF()) { | ||||||
|     bool Intrn = MF.getFunction()->hasInternalLinkage(); |     bool Intrn = MF.getFunction()->hasInternalLinkage(); | ||||||
|     OutStreamer.BeginCOFFSymbolDef(CurrentFnSym); |     OutStreamer.BeginCOFFSymbolDef(CurrentFnSym); | ||||||
|     OutStreamer.EmitCOFFSymbolStorageClass(Intrn ? COFF::C_STAT : COFF::C_EXT); |     OutStreamer.EmitCOFFSymbolStorageClass(Intrn ? COFF::IMAGE_SYM_CLASS_STATIC  | ||||||
|     OutStreamer.EmitCOFFSymbolType(COFF::DT_FCN << COFF::N_BTSHFT); |                                               : COFF::IMAGE_SYM_CLASS_EXTERNAL); | ||||||
|  |     OutStreamer.EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION | ||||||
|  |                                                << COFF::SCT_COMPLEX_TYPE_SHIFT); | ||||||
|     OutStreamer.EndCOFFSymbolDef(); |     OutStreamer.EndCOFFSymbolDef(); | ||||||
|   } |   } | ||||||
|  |  | ||||||
| @@ -582,8 +584,9 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) { | |||||||
|                             E = COFFMMI.externals_end(); |                             E = COFFMMI.externals_end(); | ||||||
|                             I != E; ++I) { |                             I != E; ++I) { | ||||||
|       OutStreamer.BeginCOFFSymbolDef(CurrentFnSym); |       OutStreamer.BeginCOFFSymbolDef(CurrentFnSym); | ||||||
|       OutStreamer.EmitCOFFSymbolStorageClass(COFF::C_EXT); |       OutStreamer.EmitCOFFSymbolStorageClass(COFF::IMAGE_SYM_CLASS_EXTERNAL); | ||||||
|       OutStreamer.EmitCOFFSymbolType(COFF::DT_FCN << COFF::N_BTSHFT); |       OutStreamer.EmitCOFFSymbolType(COFF::IMAGE_SYM_DTYPE_FUNCTION | ||||||
|  |                                                << COFF::SCT_COMPLEX_TYPE_SHIFT); | ||||||
|       OutStreamer.EndCOFFSymbolDef(); |       OutStreamer.EndCOFFSymbolDef(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,95 +0,0 @@ | |||||||
| //===--- X86COFF.h - Some definitions from COFF documentations ------------===// |  | ||||||
| // |  | ||||||
| //                     The LLVM Compiler Infrastructure |  | ||||||
| // |  | ||||||
| // This file is distributed under the University of Illinois Open Source |  | ||||||
| // License. See LICENSE.TXT for details. |  | ||||||
| // |  | ||||||
| //===----------------------------------------------------------------------===// |  | ||||||
| // |  | ||||||
| // This file just defines some symbols found in COFF documentation. They are |  | ||||||
| // used to emit function type information for COFF targets (Cygwin/Mingw32). |  | ||||||
| // |  | ||||||
| //===----------------------------------------------------------------------===// |  | ||||||
|  |  | ||||||
| #ifndef X86COFF_H |  | ||||||
| #define X86COFF_H |  | ||||||
|  |  | ||||||
| namespace COFF  |  | ||||||
| { |  | ||||||
| /// Storage class tells where and what the symbol represents |  | ||||||
| enum StorageClass { |  | ||||||
|   C_EFCN =   -1,  ///< Physical end of function |  | ||||||
|   C_NULL    = 0,  ///< No symbol |  | ||||||
|   C_AUTO    = 1,  ///< External definition |  | ||||||
|   C_EXT     = 2,  ///< External symbol |  | ||||||
|   C_STAT    = 3,  ///< Static |  | ||||||
|   C_REG     = 4,  ///< Register variable |  | ||||||
|   C_EXTDEF  = 5,  ///< External definition |  | ||||||
|   C_LABEL   = 6,  ///< Label |  | ||||||
|   C_ULABEL  = 7,  ///< Undefined label |  | ||||||
|   C_MOS     = 8,  ///< Member of structure |  | ||||||
|   C_ARG     = 9,  ///< Function argument |  | ||||||
|   C_STRTAG  = 10, ///< Structure tag |  | ||||||
|   C_MOU     = 11, ///< Member of union |  | ||||||
|   C_UNTAG   = 12, ///< Union tag |  | ||||||
|   C_TPDEF   = 13, ///< Type definition |  | ||||||
|   C_USTATIC = 14, ///< Undefined static |  | ||||||
|   C_ENTAG   = 15, ///< Enumeration tag |  | ||||||
|   C_MOE     = 16, ///< Member of enumeration |  | ||||||
|   C_REGPARM = 17, ///< Register parameter |  | ||||||
|   C_FIELD   = 18, ///< Bit field |  | ||||||
|  |  | ||||||
|   C_BLOCK  = 100, ///< ".bb" or ".eb" - beginning or end of block |  | ||||||
|   C_FCN    = 101, ///< ".bf" or ".ef" - beginning or end of function |  | ||||||
|   C_EOS    = 102, ///< End of structure |  | ||||||
|   C_FILE   = 103, ///< File name |  | ||||||
|   C_LINE   = 104, ///< Line number, reformatted as symbol |  | ||||||
|   C_ALIAS  = 105, ///< Duplicate tag |  | ||||||
|   C_HIDDEN = 106  ///< External symbol in dmert public lib |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| /// The type of the symbol. This is made up of a base type and a derived type. |  | ||||||
| /// For example, pointer to int is "pointer to T" and "int" |  | ||||||
| enum SymbolType { |  | ||||||
|   T_NULL   = 0,  ///< No type info |  | ||||||
|   T_ARG    = 1,  ///< Void function argument (only used by compiler) |  | ||||||
|   T_VOID   = 1,  ///< The same as above. Just named differently in some specs. |  | ||||||
|   T_CHAR   = 2,  ///< Character |  | ||||||
|   T_SHORT  = 3,  ///< Short integer |  | ||||||
|   T_INT    = 4,  ///< Integer |  | ||||||
|   T_LONG   = 5,  ///< Long integer |  | ||||||
|   T_FLOAT  = 6,  ///< Floating point |  | ||||||
|   T_DOUBLE = 7,  ///< Double word |  | ||||||
|   T_STRUCT = 8,  ///< Structure |  | ||||||
|   T_UNION  = 9,  ///< Union |  | ||||||
|   T_ENUM   = 10, ///< Enumeration |  | ||||||
|   T_MOE    = 11, ///< Member of enumeration |  | ||||||
|   T_UCHAR  = 12, ///< Unsigned character |  | ||||||
|   T_USHORT = 13, ///< Unsigned short |  | ||||||
|   T_UINT   = 14, ///< Unsigned integer |  | ||||||
|   T_ULONG  = 15  ///< Unsigned long |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| /// Derived type of symbol |  | ||||||
| enum SymbolDerivedType { |  | ||||||
|   DT_NON = 0, ///< No derived type |  | ||||||
|   DT_PTR = 1, ///< Pointer to T |  | ||||||
|   DT_FCN = 2, ///< Function returning T |  | ||||||
|   DT_ARY = 3  ///< Array of T |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| /// Masks for extracting parts of type |  | ||||||
| enum SymbolTypeMasks { |  | ||||||
|   N_BTMASK = 017, ///< Mask for base type |  | ||||||
|   N_TMASK  = 060  ///< Mask for derived type |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| /// Offsets of parts of type |  | ||||||
| enum Shifts { |  | ||||||
|   N_BTSHFT = 4 ///< Type is formed as (base + derived << N_BTSHIFT) |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| } |  | ||||||
|  |  | ||||||
| #endif // X86COFF_H |  | ||||||
		Reference in New Issue
	
	Block a user