Vendor import of llvm trunk r305145:
https://llvm.org/svn/llvm-project/llvm/trunk@305145
This commit is contained in:
parent
d288ef4c17
commit
7ab83427af
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/vendor/llvm/dist/; revision=319780 svn path=/vendor/llvm/llvm-trunk-r305145/; revision=319781; tag=vendor/llvm/llvm-trunk-r305145
@ -385,6 +385,7 @@ else()
|
||||
option(LLVM_ENABLE_LOCAL_SUBMODULE_VISIBILITY "Compile with -fmodules-local-submodule-visibility." ON)
|
||||
endif()
|
||||
option(LLVM_ENABLE_CXX1Y "Compile with C++1y enabled." OFF)
|
||||
option(LLVM_ENABLE_CXX1Z "Compile with C++1z enabled." OFF)
|
||||
option(LLVM_ENABLE_LIBCXX "Use libc++ if available." OFF)
|
||||
option(LLVM_ENABLE_LLD "Use lld as C and C++ linker." OFF)
|
||||
option(LLVM_ENABLE_PEDANTIC "Compile with pedantic enabled." ON)
|
||||
@ -853,7 +854,6 @@ if( LLVM_INCLUDE_UTILS )
|
||||
add_subdirectory(utils/not)
|
||||
add_subdirectory(utils/llvm-lit)
|
||||
add_subdirectory(utils/yaml-bench)
|
||||
add_subdirectory(utils/unittest)
|
||||
else()
|
||||
if ( LLVM_INCLUDE_TESTS )
|
||||
message(FATAL_ERROR "Including tests when not building utils will not work.
|
||||
@ -897,6 +897,10 @@ if( LLVM_INCLUDE_TESTS )
|
||||
endif()
|
||||
add_subdirectory(test)
|
||||
add_subdirectory(unittests)
|
||||
if( LLVM_INCLUDE_UTILS )
|
||||
add_subdirectory(utils/unittest)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
# This utility is used to prevent crashing tests from calling Dr. Watson on
|
||||
# Windows.
|
||||
|
@ -611,6 +611,12 @@ func (t Type) StructElementTypes() []Type {
|
||||
}
|
||||
|
||||
// Operations on array, pointer, and vector types (sequence types)
|
||||
func (t Type) Subtypes() (ret []Type) {
|
||||
ret = make([]Type, C.LLVMGetNumContainedTypes(t.C))
|
||||
C.LLVMGetSubtypes(t.C, llvmTypeRefPtr(&ret[0]))
|
||||
return
|
||||
}
|
||||
|
||||
func ArrayType(elementType Type, elementCount int) (t Type) {
|
||||
t.C = C.LLVMArrayType(elementType.C, C.unsigned(elementCount))
|
||||
return
|
||||
|
@ -134,3 +134,29 @@ func TestDebugLoc(t *testing.T) {
|
||||
t.Errorf("Got metadata %v as scope, though wanted %v", loc.Scope.C, scope.C)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSubtypes(t *testing.T) {
|
||||
cont := NewContext()
|
||||
defer cont.Dispose()
|
||||
|
||||
int_pointer := PointerType(cont.Int32Type(), 0)
|
||||
int_inner := int_pointer.Subtypes()
|
||||
if len(int_inner) != 1 {
|
||||
t.Errorf("Got size %d, though wanted 1")
|
||||
}
|
||||
if int_inner[0] != cont.Int32Type() {
|
||||
t.Errorf("Expected int32 type")
|
||||
}
|
||||
|
||||
st_pointer := cont.StructType([]Type{cont.Int32Type(), cont.Int8Type()}, false)
|
||||
st_inner := st_pointer.Subtypes()
|
||||
if len(st_inner) != 2 {
|
||||
t.Errorf("Got size %d, though wanted 2")
|
||||
}
|
||||
if st_inner[0] != cont.Int32Type() {
|
||||
t.Errorf("Expected first struct field to be int32")
|
||||
}
|
||||
if st_inner[1] != cont.Int8Type() {
|
||||
t.Errorf("Expected second struct field to be int8")
|
||||
}
|
||||
}
|
||||
|
@ -459,6 +459,8 @@ external is_packed : lltype -> bool = "llvm_is_packed"
|
||||
external is_opaque : lltype -> bool = "llvm_is_opaque"
|
||||
|
||||
(*--... Operations on pointer, vector, and array types .....................--*)
|
||||
|
||||
external subtypes : lltype -> lltype array = "llvm_subtypes"
|
||||
external array_type : lltype -> int -> lltype = "llvm_array_type"
|
||||
external pointer_type : lltype -> lltype = "llvm_pointer_type"
|
||||
external qualified_pointer_type : lltype -> int -> lltype
|
||||
|
@ -658,6 +658,9 @@ val is_opaque : lltype -> bool
|
||||
|
||||
(** {7 Operations on pointer, vector, and array types} *)
|
||||
|
||||
(** [subtypes ty] returns [ty]'s subtypes *)
|
||||
val subtypes : lltype -> lltype array
|
||||
|
||||
(** [array_type ty n] returns the array type containing [n] elements of type
|
||||
[ty]. See the method [llvm::ArrayType::get]. *)
|
||||
val array_type : lltype -> int -> lltype
|
||||
|
@ -506,6 +506,20 @@ CAMLprim value llvm_is_opaque(LLVMTypeRef StructTy) {
|
||||
|
||||
/*--... Operations on array, pointer, and vector types .....................--*/
|
||||
|
||||
/* lltype -> lltype array */
|
||||
CAMLprim value llvm_subtypes(LLVMTypeRef Ty) {
|
||||
CAMLparam0();
|
||||
CAMLlocal1(Arr);
|
||||
|
||||
unsigned Size = LLVMGetNumContainedTypes(Ty);
|
||||
|
||||
Arr = caml_alloc(Size, 0);
|
||||
|
||||
LLVMGetSubtypes(Ty, (LLVMTypeRef *) Arr);
|
||||
|
||||
CAMLreturn(Arr);
|
||||
}
|
||||
|
||||
/* lltype -> int -> lltype */
|
||||
CAMLprim LLVMTypeRef llvm_array_type(LLVMTypeRef ElementTy, value Count) {
|
||||
return LLVMArrayType(ElementTy, Int_val(Count));
|
||||
|
@ -101,6 +101,10 @@ else()
|
||||
message(FATAL_ERROR "Unknown value for LLVM_ABI_BREAKING_CHECKS: \"${LLVM_ABI_BREAKING_CHECKS}\"!")
|
||||
endif()
|
||||
|
||||
if( LLVM_REVERSE_ITERATION )
|
||||
set( LLVM_ENABLE_REVERSE_ITERATION 1 )
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
|
||||
if(CYGWIN)
|
||||
@ -381,6 +385,9 @@ elseif( LLVM_COMPILER_IS_GCC_COMPATIBLE )
|
||||
if (LLVM_ENABLE_CXX1Y)
|
||||
check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
|
||||
append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
|
||||
elseif(LLVM_ENABLE_CXX1Z)
|
||||
check_cxx_compiler_flag("-std=c++1z" CXX_SUPPORTS_CXX1Z)
|
||||
append_if(CXX_SUPPORTS_CXX1Z "-std=c++1z" CMAKE_CXX_FLAGS)
|
||||
else()
|
||||
check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
|
||||
if (CXX_SUPPORTS_CXX11)
|
||||
|
@ -30,19 +30,43 @@ function(tablegen project ofn)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
|
||||
# Generate tablegen output in a temporary file.
|
||||
COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${LLVM_TABLEGEN_FLAGS}
|
||||
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
|
||||
# The file in LLVM_TARGET_DEFINITIONS may be not in the current
|
||||
# directory and local_tds may not contain it, so we must
|
||||
# explicitly list it here:
|
||||
DEPENDS ${${project}_TABLEGEN_TARGET} ${local_tds} ${global_tds}
|
||||
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
|
||||
COMMENT "Building ${ofn}..."
|
||||
)
|
||||
# We need both _TABLEGEN_TARGET and _TABLEGEN_EXE in the DEPENDS list
|
||||
# (both the target and the file) to have .inc files rebuilt on
|
||||
# a tablegen change, as cmake does not propagate file-level dependencies
|
||||
# of custom targets. See the following ticket for more information:
|
||||
# https://cmake.org/Bug/view.php?id=15858
|
||||
# We could always have just one dependency on both the target and
|
||||
# the file, but these 2 cases would produce cleaner cmake files.
|
||||
if (${${project}_TABLEGEN_TARGET} STREQUAL ${${project}_TABLEGEN_EXE})
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
|
||||
# Generate tablegen output in a temporary file.
|
||||
COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${LLVM_TABLEGEN_FLAGS}
|
||||
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
|
||||
# The file in LLVM_TARGET_DEFINITIONS may be not in the current
|
||||
# directory and local_tds may not contain it, so we must
|
||||
# explicitly list it here:
|
||||
DEPENDS ${${project}_TABLEGEN_TARGET} ${local_tds} ${global_tds}
|
||||
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
|
||||
COMMENT "Building ${ofn}..."
|
||||
)
|
||||
else()
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
|
||||
# Generate tablegen output in a temporary file.
|
||||
COMMAND ${${project}_TABLEGEN_EXE} ${ARGN} -I ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${LLVM_TABLEGEN_FLAGS}
|
||||
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/${ofn}.tmp
|
||||
# The file in LLVM_TARGET_DEFINITIONS may be not in the current
|
||||
# directory and local_tds may not contain it, so we must
|
||||
# explicitly list it here:
|
||||
DEPENDS ${${project}_TABLEGEN_TARGET} ${${project}_TABLEGEN_EXE}
|
||||
${local_tds} ${global_tds}
|
||||
${LLVM_TARGET_DEFINITIONS_ABSOLUTE}
|
||||
COMMENT "Building ${ofn}..."
|
||||
)
|
||||
endif()
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${ofn}
|
||||
# Only update the real output file if there are any differences.
|
||||
# This prevents recompilation of all the files depending on it if there
|
||||
|
3558
docs/AMDGPUUsage.rst
3558
docs/AMDGPUUsage.rst
File diff suppressed because it is too large
Load Diff
@ -2642,59 +2642,6 @@ to ensure valid register usage and operand types.
|
||||
The AMDGPU backend
|
||||
------------------
|
||||
|
||||
The AMDGPU code generator lives in the lib/Target/AMDGPU directory, and is an
|
||||
open source native AMD GCN ISA code generator.
|
||||
|
||||
Target triples supported
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The following are the known target triples that are supported by the AMDGPU
|
||||
backend.
|
||||
|
||||
* **amdgcn--** --- AMD GCN GPUs (AMDGPU.7.0.0+)
|
||||
* **amdgcn--amdhsa** --- AMD GCN GPUs (AMDGPU.7.0.0+) with HSA support
|
||||
* **r600--** --- AMD GPUs HD2XXX-HD6XXX
|
||||
|
||||
Relocations
|
||||
^^^^^^^^^^^
|
||||
|
||||
Supported relocatable fields are:
|
||||
|
||||
* **word32** --- This specifies a 32-bit field occupying 4 bytes with arbitrary
|
||||
byte alignment. These values use the same byte order as other word values in
|
||||
the AMD GPU architecture
|
||||
* **word64** --- This specifies a 64-bit field occupying 8 bytes with arbitrary
|
||||
byte alignment. These values use the same byte order as other word values in
|
||||
the AMD GPU architecture
|
||||
|
||||
Following notations are used for specifying relocation calculations:
|
||||
|
||||
* **A** --- Represents the addend used to compute the value of the relocatable
|
||||
field
|
||||
* **G** --- Represents the offset into the global offset table at which the
|
||||
relocation entry’s symbol will reside during execution.
|
||||
* **GOT** --- Represents the address of the global offset table.
|
||||
* **P** --- Represents the place (section offset or address) of the storage unit
|
||||
being relocated (computed using ``r_offset``)
|
||||
* **S** --- Represents the value of the symbol whose index resides in the
|
||||
relocation entry
|
||||
|
||||
AMDGPU Backend generates *Elf64_Rela* relocation records with the following
|
||||
supported relocation types:
|
||||
|
||||
========================== ===== ========== ==============================
|
||||
Relocation type Value Field Calculation
|
||||
========================== ===== ========== ==============================
|
||||
``R_AMDGPU_NONE`` 0 ``none`` ``none``
|
||||
``R_AMDGPU_ABS32_LO`` 1 ``word32`` (S + A) & 0xFFFFFFFF
|
||||
``R_AMDGPU_ABS32_HI`` 2 ``word32`` (S + A) >> 32
|
||||
``R_AMDGPU_ABS64`` 3 ``word64`` S + A
|
||||
``R_AMDGPU_REL32`` 4 ``word32`` S + A - P
|
||||
``R_AMDGPU_REL64`` 5 ``word64`` S + A - P
|
||||
``R_AMDGPU_ABS32`` 6 ``word32`` S + A
|
||||
``R_AMDGPU_GOTPCREL`` 7 ``word32`` G + GOT + A - P
|
||||
``R_AMDGPU_GOTPCREL32_LO`` 8 ``word32`` (G + GOT + A - P) & 0xFFFFFFFF
|
||||
``R_AMDGPU_GOTPCREL32_HI`` 9 ``word32`` (G + GOT + A - P) >> 32
|
||||
``R_AMDGPU_REL32_LO`` 10 ``word32`` (S + A - P) & 0xFFFFFFFF
|
||||
``R_AMDGPU_REL32_HI`` 11 ``word32`` (S + A - P) >> 32
|
||||
========================== ===== ========== ==============================
|
||||
The AMDGPU code generator lives in the ``lib/Target/AMDGPU``
|
||||
directory. This code generator is capable of targeting a variety of
|
||||
AMD GPU processors. Refer to :doc:`AMDGPUUsage` for more information.
|
||||
|
@ -72,16 +72,7 @@ Other documents, collections, notes
|
||||
AMDGPU
|
||||
------
|
||||
|
||||
* `AMD R6xx shader ISA <http://developer.amd.com/wordpress/media/2012/10/R600_Instruction_Set_Architecture.pdf>`_
|
||||
* `AMD R7xx shader ISA <http://developer.amd.com/wordpress/media/2012/10/R700-Family_Instruction_Set_Architecture.pdf>`_
|
||||
* `AMD Evergreen shader ISA <http://developer.amd.com/wordpress/media/2012/10/AMD_Evergreen-Family_Instruction_Set_Architecture.pdf>`_
|
||||
* `AMD Cayman/Trinity shader ISA <http://developer.amd.com/wordpress/media/2012/10/AMD_HD_6900_Series_Instruction_Set_Architecture.pdf>`_
|
||||
* `AMD Southern Islands Series ISA <http://developer.amd.com/wordpress/media/2012/12/AMD_Southern_Islands_Instruction_Set_Architecture.pdf>`_
|
||||
* `AMD Sea Islands Series ISA <http://developer.amd.com/wordpress/media/2013/07/AMD_Sea_Islands_Instruction_Set_Architecture.pdf>`_
|
||||
* `AMD GCN3 Instruction Set Architecture <http://amd-dev.wpengine.netdna-cdn.com/wordpress/media/2013/12/AMD_GCN3_Instruction_Set_Architecture_rev1.1.pdf>`__
|
||||
* `AMD GPU Programming Guide <http://developer.amd.com/download/AMD_Accelerated_Parallel_Processing_OpenCL_Programming_Guide.pdf>`_
|
||||
* `AMD Compute Resources <http://developer.amd.com/tools/heterogeneous-computing/amd-accelerated-parallel-processing-app-sdk/documentation/>`_
|
||||
* `AMDGPU Compute Application Binary Interface <https://github.com/RadeonOpenCompute/ROCm-ComputeABI-Doc/blob/master/AMDGPU-ABI.md>`__
|
||||
Refer to :doc:`AMDGPUUsage` for additional documentation.
|
||||
|
||||
RISC-V
|
||||
------
|
||||
|
@ -6691,15 +6691,14 @@ Semantics:
|
||||
The value produced is ``op1`` \* 2\ :sup:`op2` mod 2\ :sup:`n`,
|
||||
where ``n`` is the width of the result. If ``op2`` is (statically or
|
||||
dynamically) equal to or larger than the number of bits in
|
||||
``op1``, the result is undefined. If the arguments are vectors, each
|
||||
vector element of ``op1`` is shifted by the corresponding shift amount
|
||||
in ``op2``.
|
||||
``op1``, this instruction returns a :ref:`poison value <poisonvalues>`.
|
||||
If the arguments are vectors, each vector element of ``op1`` is shifted
|
||||
by the corresponding shift amount in ``op2``.
|
||||
|
||||
If the ``nuw`` keyword is present, then the shift produces a :ref:`poison
|
||||
value <poisonvalues>` if it shifts out any non-zero bits. If the
|
||||
``nsw`` keyword is present, then the shift produces a :ref:`poison
|
||||
value <poisonvalues>` if it shifts out any bits that disagree with the
|
||||
resultant sign bit.
|
||||
If the ``nuw`` keyword is present, then the shift produces a poison
|
||||
value if it shifts out any non-zero bits.
|
||||
If the ``nsw`` keyword is present, then the shift produces a poison
|
||||
value it shifts out any bits that disagree with the resultant sign bit.
|
||||
|
||||
Example:
|
||||
""""""""
|
||||
@ -6742,13 +6741,12 @@ Semantics:
|
||||
This instruction always performs a logical shift right operation. The
|
||||
most significant bits of the result will be filled with zero bits after
|
||||
the shift. If ``op2`` is (statically or dynamically) equal to or larger
|
||||
than the number of bits in ``op1``, the result is undefined. If the
|
||||
arguments are vectors, each vector element of ``op1`` is shifted by the
|
||||
corresponding shift amount in ``op2``.
|
||||
than the number of bits in ``op1``, this instruction returns a :ref:`poison
|
||||
value <poisonvalues>`. If the arguments are vectors, each vector element
|
||||
of ``op1`` is shifted by the corresponding shift amount in ``op2``.
|
||||
|
||||
If the ``exact`` keyword is present, the result value of the ``lshr`` is
|
||||
a :ref:`poison value <poisonvalues>` if any of the bits shifted out are
|
||||
non-zero.
|
||||
a poison value if any of the bits shifted out are non-zero.
|
||||
|
||||
Example:
|
||||
""""""""
|
||||
@ -6793,13 +6791,12 @@ Semantics:
|
||||
This instruction always performs an arithmetic shift right operation,
|
||||
The most significant bits of the result will be filled with the sign bit
|
||||
of ``op1``. If ``op2`` is (statically or dynamically) equal to or larger
|
||||
than the number of bits in ``op1``, the result is undefined. If the
|
||||
arguments are vectors, each vector element of ``op1`` is shifted by the
|
||||
corresponding shift amount in ``op2``.
|
||||
than the number of bits in ``op1``, this instruction returns a :ref:`poison
|
||||
value <poisonvalues>`. If the arguments are vectors, each vector element
|
||||
of ``op1`` is shifted by the corresponding shift amount in ``op2``.
|
||||
|
||||
If the ``exact`` keyword is present, the result value of the ``ashr`` is
|
||||
a :ref:`poison value <poisonvalues>` if any of the bits shifted out are
|
||||
non-zero.
|
||||
a poison value if any of the bits shifted out are non-zero.
|
||||
|
||||
Example:
|
||||
""""""""
|
||||
|
@ -43,6 +43,17 @@ Non-comprehensive list of changes in this release
|
||||
* LLVM's ``WeakVH`` has been renamed to ``WeakTrackingVH`` and a new ``WeakVH``
|
||||
has been introduced. The new ``WeakVH`` nulls itself out on deletion, but
|
||||
does not track values across RAUW.
|
||||
|
||||
* A new library named ``BinaryFormat`` has been created which holds a collection
|
||||
of code which previously lived in ``Support``. This includes the
|
||||
``file_magic`` structure and ``identify_magic`` functions, as well as all the
|
||||
structure and type definitions for DWARF, ELF, COFF, WASM, and MachO file
|
||||
formats.
|
||||
|
||||
* The tool ``llvm-pdbdump`` has been renamed ``llvm-pdbutil`` to better reflect
|
||||
its nature as a general purpose PDB manipulation / diagnostics tool that does
|
||||
more than just dumping contents.
|
||||
|
||||
|
||||
* ... next change ...
|
||||
|
||||
|
@ -360,10 +360,10 @@ For API clients and LLVM developers.
|
||||
Answers some questions about the new Attributes infrastructure.
|
||||
|
||||
:doc:`NVPTXUsage`
|
||||
This document describes using the NVPTX back-end to compile GPU kernels.
|
||||
This document describes using the NVPTX backend to compile GPU kernels.
|
||||
|
||||
:doc:`AMDGPUUsage`
|
||||
This document describes how to use the AMDGPU back-end.
|
||||
This document describes using the AMDGPU backend to compile GPU kernels.
|
||||
|
||||
:doc:`StackMaps`
|
||||
LLVM support for mapping instruction addresses to the location of
|
||||
|
@ -49,7 +49,7 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/BinaryFormat/Dwarf.h"
|
||||
#include "llvm/ExecutionEngine/MCJIT.h"
|
||||
#include "llvm/ExecutionEngine/SectionMemoryManager.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
@ -59,7 +59,7 @@
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/LegacyPassManager.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
#include "llvm/IR/Verifier.h"
|
||||
#include "llvm/Support/TargetSelect.h"
|
||||
#include "llvm/Target/TargetOptions.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
|
@ -1039,6 +1039,20 @@ LLVMBool LLVMIsOpaqueStruct(LLVMTypeRef StructTy);
|
||||
*/
|
||||
LLVMTypeRef LLVMGetElementType(LLVMTypeRef Ty);
|
||||
|
||||
/**
|
||||
* Returns type's subtypes
|
||||
*
|
||||
* @see llvm::Type::subtypes()
|
||||
*/
|
||||
void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr);
|
||||
|
||||
/**
|
||||
* Return the number of types in the derived type.
|
||||
*
|
||||
* @see llvm::Type::getNumContainedTypes()
|
||||
*/
|
||||
unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp);
|
||||
|
||||
/**
|
||||
* Create a fixed size array type that refers to a specific type.
|
||||
*
|
||||
|
@ -19,9 +19,9 @@
|
||||
#ifndef LLVM_C_EXECUTIONENGINE_H
|
||||
#define LLVM_C_EXECUTIONENGINE_H
|
||||
|
||||
#include "llvm-c/Types.h"
|
||||
#include "llvm-c/Target.h"
|
||||
#include "llvm-c/TargetMachine.h"
|
||||
#include "llvm-c/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -14,8 +14,8 @@
|
||||
#ifndef LLVM_C_SUPPORT_H
|
||||
#define LLVM_C_SUPPORT_H
|
||||
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include "llvm-c/Types.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -19,8 +19,8 @@
|
||||
#ifndef LLVM_C_TARGETMACHINE_H
|
||||
#define LLVM_C_TARGETMACHINE_H
|
||||
|
||||
#include "llvm-c/Types.h"
|
||||
#include "llvm-c/Target.h"
|
||||
#include "llvm-c/Types.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -392,6 +392,11 @@ class LLVM_NODISCARD APInt {
|
||||
/// not.
|
||||
bool isNullValue() const { return !*this; }
|
||||
|
||||
/// \brief Determine if this is a value of 1.
|
||||
///
|
||||
/// This checks to see if the value of this APInt is one.
|
||||
bool isOneValue() const { return getActiveBits() == 1; }
|
||||
|
||||
/// \brief Determine if this is the largest unsigned value.
|
||||
///
|
||||
/// This checks to see if the value of this APInt is the maximum unsigned
|
||||
|
@ -52,7 +52,6 @@ struct GraphTraits {
|
||||
// Return total number of nodes in the graph
|
||||
//
|
||||
|
||||
|
||||
// If anyone tries to use this class without having an appropriate
|
||||
// specialization, make an error. If you get this error, it's because you
|
||||
// need to include the appropriate specialization of GraphTraits<> for your
|
||||
|
@ -16,16 +16,16 @@
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/FoldingSet.h"
|
||||
#include "llvm/ADT/iterator.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/iterator.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include <cassert>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <iterator>
|
||||
#include <new>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -19,8 +19,8 @@
|
||||
#include "llvm/ADT/PointerIntPair.h"
|
||||
#include "llvm/Support/PointerLikeTypeTraits.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -17,9 +17,9 @@
|
||||
#define LLVM_ADT_POSTORDERITERATOR_H
|
||||
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include <iterator>
|
||||
#include <set>
|
||||
#include <utility>
|
||||
|
@ -17,8 +17,8 @@
|
||||
#define LLVM_ADT_PRIORITYWORKLIST_H
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
|
@ -232,16 +232,6 @@ template <class T> scc_iterator<T> scc_end(const T &G) {
|
||||
return scc_iterator<T>::end(G);
|
||||
}
|
||||
|
||||
/// \brief Construct the begin iterator for a deduced graph type T's Inverse<T>.
|
||||
template <class T> scc_iterator<Inverse<T>> scc_begin(const Inverse<T> &G) {
|
||||
return scc_iterator<Inverse<T>>::begin(G);
|
||||
}
|
||||
|
||||
/// \brief Construct the end iterator for a deduced graph type T's Inverse<T>.
|
||||
template <class T> scc_iterator<Inverse<T>> scc_end(const Inverse<T> &G) {
|
||||
return scc_iterator<Inverse<T>>::end(G);
|
||||
}
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_ADT_SCCITERATOR_H
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include "llvm/Support/type_traits.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <initializer_list>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
@ -31,8 +31,12 @@ namespace llvm {
|
||||
|
||||
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
|
||||
template <class T = void> struct ReverseIterate { static bool value; };
|
||||
#if LLVM_ENABLE_REVERSE_ITERATION
|
||||
template <class T> bool ReverseIterate<T>::value = true;
|
||||
#else
|
||||
template <class T> bool ReverseIterate<T>::value = false;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/// SmallPtrSetImplBase - This is the common code shared among all the
|
||||
/// SmallPtrSet<>'s, which is almost everything. SmallPtrSet has two modes, one
|
||||
|
@ -388,7 +388,10 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T, isPodLike<T>::value> {
|
||||
void swap(SmallVectorImpl &RHS);
|
||||
|
||||
/// Add the specified range to the end of the SmallVector.
|
||||
template<typename in_iter>
|
||||
template <typename in_iter,
|
||||
typename = typename std::enable_if<std::is_convertible<
|
||||
typename std::iterator_traits<in_iter>::iterator_category,
|
||||
std::input_iterator_tag>::value>::type>
|
||||
void append(in_iter in_start, in_iter in_end) {
|
||||
size_type NumInputs = std::distance(in_start, in_end);
|
||||
// Grow allocated space if needed.
|
||||
@ -426,7 +429,11 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T, isPodLike<T>::value> {
|
||||
std::uninitialized_fill(this->begin(), this->end(), Elt);
|
||||
}
|
||||
|
||||
template <typename in_iter> void assign(in_iter in_start, in_iter in_end) {
|
||||
template <typename in_iter,
|
||||
typename = typename std::enable_if<std::is_convertible<
|
||||
typename std::iterator_traits<in_iter>::iterator_category,
|
||||
std::input_iterator_tag>::value>::type>
|
||||
void assign(in_iter in_start, in_iter in_end) {
|
||||
clear();
|
||||
append(in_start, in_end);
|
||||
}
|
||||
@ -579,7 +586,10 @@ class SmallVectorImpl : public SmallVectorTemplateBase<T, isPodLike<T>::value> {
|
||||
return I;
|
||||
}
|
||||
|
||||
template<typename ItTy>
|
||||
template <typename ItTy,
|
||||
typename = typename std::enable_if<std::is_convertible<
|
||||
typename std::iterator_traits<ItTy>::iterator_category,
|
||||
std::input_iterator_tag>::value>::type>
|
||||
iterator insert(iterator I, ItTy From, ItTy To) {
|
||||
// Convert iterator to elt# to avoid invalidating iterator when we reserve()
|
||||
size_t InsertElt = I - this->begin();
|
||||
@ -860,7 +870,10 @@ class SmallVector : public SmallVectorImpl<T> {
|
||||
this->assign(Size, Value);
|
||||
}
|
||||
|
||||
template<typename ItTy>
|
||||
template <typename ItTy,
|
||||
typename = typename std::enable_if<std::is_convertible<
|
||||
typename std::iterator_traits<ItTy>::iterator_category,
|
||||
std::input_iterator_tag>::value>::type>
|
||||
SmallVector(ItTy S, ItTy E) : SmallVectorImpl<T>(N) {
|
||||
this->append(S, E);
|
||||
}
|
||||
|
@ -21,9 +21,9 @@
|
||||
#ifndef LLVM_ADT_SPARSEMULTISET_H
|
||||
#define LLVM_ADT_SPARSEMULTISET_H
|
||||
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/SparseSet.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <cstdlib>
|
||||
|
@ -15,11 +15,11 @@
|
||||
#define LLVM_ADT_STRINGEXTRAS_H
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include <iterator>
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <cstring>
|
||||
#include <iterator>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
|
@ -18,8 +18,8 @@
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
|
@ -19,8 +19,8 @@
|
||||
#ifndef LLVM_ADT_ITERATOR_RANGE_H
|
||||
#define LLVM_ADT_ITERATOR_RANGE_H
|
||||
|
||||
#include <utility>
|
||||
#include <iterator>
|
||||
#include <utility>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -38,11 +38,11 @@
|
||||
#ifndef LLVM_ANALYSIS_ALIASANALYSIS_H
|
||||
#define LLVM_ANALYSIS_ALIASANALYSIS_H
|
||||
|
||||
#include "llvm/Analysis/MemoryLocation.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/Metadata.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/Analysis/MemoryLocation.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
class BasicAAResult;
|
||||
|
@ -21,8 +21,8 @@
|
||||
#include "llvm/ADT/SmallSet.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/IR/ValueHandle.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include <memory>
|
||||
|
||||
|
@ -26,6 +26,7 @@
|
||||
|
||||
namespace llvm {
|
||||
class LoopInfo;
|
||||
class TargetLibraryInfo;
|
||||
class raw_ostream;
|
||||
|
||||
/// \brief Analysis providing branch probability information.
|
||||
@ -43,8 +44,9 @@ class raw_ostream;
|
||||
class BranchProbabilityInfo {
|
||||
public:
|
||||
BranchProbabilityInfo() {}
|
||||
BranchProbabilityInfo(const Function &F, const LoopInfo &LI) {
|
||||
calculate(F, LI);
|
||||
BranchProbabilityInfo(const Function &F, const LoopInfo &LI,
|
||||
const TargetLibraryInfo *TLI = nullptr) {
|
||||
calculate(F, LI, TLI);
|
||||
}
|
||||
|
||||
BranchProbabilityInfo(BranchProbabilityInfo &&Arg)
|
||||
@ -116,7 +118,8 @@ class BranchProbabilityInfo {
|
||||
return IsLikely ? LikelyProb : LikelyProb.getCompl();
|
||||
}
|
||||
|
||||
void calculate(const Function &F, const LoopInfo &LI);
|
||||
void calculate(const Function &F, const LoopInfo &LI,
|
||||
const TargetLibraryInfo *TLI = nullptr);
|
||||
|
||||
/// Forget analysis results for the given basic block.
|
||||
void eraseBlock(const BasicBlock *BB);
|
||||
@ -171,7 +174,7 @@ class BranchProbabilityInfo {
|
||||
bool calcColdCallHeuristics(const BasicBlock *BB);
|
||||
bool calcPointerHeuristics(const BasicBlock *BB);
|
||||
bool calcLoopBranchHeuristics(const BasicBlock *BB, const LoopInfo &LI);
|
||||
bool calcZeroHeuristics(const BasicBlock *BB);
|
||||
bool calcZeroHeuristics(const BasicBlock *BB, const TargetLibraryInfo *TLI);
|
||||
bool calcFloatingPointHeuristics(const BasicBlock *BB);
|
||||
bool calcInvokeHeuristics(const BasicBlock *BB);
|
||||
};
|
||||
|
@ -31,6 +31,7 @@ class DataLayout;
|
||||
class Function;
|
||||
class GlobalValue;
|
||||
class Instruction;
|
||||
class ImmutableCallSite;
|
||||
class TargetLibraryInfo;
|
||||
class Type;
|
||||
|
||||
@ -125,11 +126,12 @@ Constant *ConstantFoldLoadThroughGEPIndices(Constant *C,
|
||||
|
||||
/// canConstantFoldCallTo - Return true if its even possible to fold a call to
|
||||
/// the specified function.
|
||||
bool canConstantFoldCallTo(const Function *F);
|
||||
bool canConstantFoldCallTo(ImmutableCallSite CS, const Function *F);
|
||||
|
||||
/// ConstantFoldCall - Attempt to constant fold a call to the specified function
|
||||
/// with the specified arguments, returning null if unsuccessful.
|
||||
Constant *ConstantFoldCall(Function *F, ArrayRef<Constant *> Operands,
|
||||
Constant *ConstantFoldCall(ImmutableCallSite CS, Function *F,
|
||||
ArrayRef<Constant *> Operands,
|
||||
const TargetLibraryInfo *TLI = nullptr);
|
||||
|
||||
/// \brief Check whether the given call has no side-effects.
|
||||
|
@ -22,11 +22,11 @@
|
||||
#ifndef LLVM_ANALYSIS_DEMANDED_BITS_H
|
||||
#define LLVM_ANALYSIS_DEMANDED_BITS_H
|
||||
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/ADT/APInt.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
#include "llvm/Pass.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
#ifndef LLVM_ANALYSIS_INLINECOST_H
|
||||
#define LLVM_ANALYSIS_INLINECOST_H
|
||||
|
||||
#include "llvm/Analysis/CallGraphSCCPass.h"
|
||||
#include "llvm/Analysis/AssumptionCache.h"
|
||||
#include "llvm/Analysis/CallGraphSCCPass.h"
|
||||
#include <cassert>
|
||||
#include <climits>
|
||||
|
||||
|
@ -41,6 +41,7 @@ template <class T> class ArrayRef;
|
||||
class AssumptionCache;
|
||||
class DominatorTree;
|
||||
class Instruction;
|
||||
class ImmutableCallSite;
|
||||
class DataLayout;
|
||||
class FastMathFlags;
|
||||
struct LoopStandardAnalysisResults;
|
||||
@ -194,11 +195,12 @@ Value *SimplifyFPBinOp(unsigned Opcode, Value *LHS, Value *RHS,
|
||||
|
||||
/// Given a function and iterators over arguments, fold the result or return
|
||||
/// null.
|
||||
Value *SimplifyCall(Value *V, User::op_iterator ArgBegin,
|
||||
Value *SimplifyCall(ImmutableCallSite CS, Value *V, User::op_iterator ArgBegin,
|
||||
User::op_iterator ArgEnd, const SimplifyQuery &Q);
|
||||
|
||||
/// Given a function and set of arguments, fold the result or return null.
|
||||
Value *SimplifyCall(Value *V, ArrayRef<Value *> Args, const SimplifyQuery &Q);
|
||||
Value *SimplifyCall(ImmutableCallSite CS, Value *V, ArrayRef<Value *> Args,
|
||||
const SimplifyQuery &Q);
|
||||
|
||||
/// See if we can compute a simplified version of this instruction. If not,
|
||||
/// return null.
|
||||
|
@ -24,6 +24,7 @@ namespace llvm {
|
||||
class AnalysisUsage;
|
||||
class Function;
|
||||
class LoopInfo;
|
||||
class TargetLibraryInfo;
|
||||
|
||||
/// \brief This is an alternative analysis pass to
|
||||
/// BranchProbabilityInfoWrapperPass. The difference is that with this pass the
|
||||
@ -55,14 +56,15 @@ class LazyBranchProbabilityInfoPass : public FunctionPass {
|
||||
/// analysis without paying for the overhead if BPI doesn't end up being used.
|
||||
class LazyBranchProbabilityInfo {
|
||||
public:
|
||||
LazyBranchProbabilityInfo(const Function *F, const LoopInfo *LI)
|
||||
: Calculated(false), F(F), LI(LI) {}
|
||||
LazyBranchProbabilityInfo(const Function *F, const LoopInfo *LI,
|
||||
const TargetLibraryInfo *TLI)
|
||||
: Calculated(false), F(F), LI(LI), TLI(TLI) {}
|
||||
|
||||
/// Retrieve the BPI with the branch probabilities computed.
|
||||
BranchProbabilityInfo &getCalculated() {
|
||||
if (!Calculated) {
|
||||
assert(F && LI && "call setAnalysis");
|
||||
BPI.calculate(*F, *LI);
|
||||
BPI.calculate(*F, *LI, TLI);
|
||||
Calculated = true;
|
||||
}
|
||||
return BPI;
|
||||
@ -77,6 +79,7 @@ class LazyBranchProbabilityInfoPass : public FunctionPass {
|
||||
bool Calculated;
|
||||
const Function *F;
|
||||
const LoopInfo *LI;
|
||||
const TargetLibraryInfo *TLI;
|
||||
};
|
||||
|
||||
std::unique_ptr<LazyBranchProbabilityInfo> LBPI;
|
||||
|
@ -100,8 +100,11 @@ class LazyValueInfo {
|
||||
/// Inform the analysis cache that we have erased a block.
|
||||
void eraseBlock(BasicBlock *BB);
|
||||
|
||||
/// Print the \LazyValueInfoCache.
|
||||
void printCache(Function &F, raw_ostream &OS);
|
||||
/// Print the \LazyValueInfo Analysis.
|
||||
/// We pass in the DTree that is required for identifying which basic blocks
|
||||
/// we can solve/print for, in the LVIPrinter. The DT is optional
|
||||
/// in LVI, so we need to pass it here as an argument.
|
||||
void printLVI(Function &F, DominatorTree &DTree, raw_ostream &OS);
|
||||
|
||||
// For old PM pass. Delete once LazyValueInfoWrapperPass is gone.
|
||||
void releaseMemory();
|
||||
|
@ -17,8 +17,8 @@
|
||||
|
||||
#include "llvm/ADT/DepthFirstIterator.h"
|
||||
#include "llvm/ADT/PostOrderIterator.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SetVector.h"
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
|
||||
|
@ -15,8 +15,8 @@
|
||||
#define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/PointerSumType.h"
|
||||
#include "llvm/ADT/PointerEmbeddedInt.h"
|
||||
#include "llvm/ADT/PointerSumType.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
|
@ -34,6 +34,7 @@
|
||||
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/Analysis/MemorySSA.h"
|
||||
#include "llvm/IR/BasicBlock.h"
|
||||
#include "llvm/IR/Dominators.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
@ -45,7 +46,6 @@
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/Casting.h"
|
||||
#include "llvm/Support/ErrorHandling.h"
|
||||
#include "llvm/Analysis/MemorySSA.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -23,8 +23,8 @@
|
||||
#ifndef LLVM_LIB_ANALYSIS_OBJCARCANALYSISUTILS_H
|
||||
#define LLVM_LIB_ANALYSIS_OBJCARCANALYSISUTILS_H
|
||||
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
#include "llvm/Analysis/AliasAnalysis.h"
|
||||
#include "llvm/Analysis/ObjCARCInstKind.h"
|
||||
#include "llvm/Analysis/Passes.h"
|
||||
|
@ -10,8 +10,8 @@
|
||||
#ifndef LLVM_ANALYSIS_OBJCARCINSTKIND_H
|
||||
#define LLVM_ANALYSIS_OBJCARCINSTKIND_H
|
||||
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace objcarc {
|
||||
|
@ -36,8 +36,8 @@
|
||||
#ifndef LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
|
||||
#define LLVM_ANALYSIS_SCALAREVOLUTIONNORMALIZATION_H
|
||||
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
||||
|
||||
namespace llvm {
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/Triple.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
@ -239,6 +240,13 @@ class TargetLibraryInfo {
|
||||
return Impl->getLibFunc(FDecl, F);
|
||||
}
|
||||
|
||||
/// If a callsite does not have the 'nobuiltin' attribute, return if the
|
||||
/// called function is a known library function and set F to that function.
|
||||
bool getLibFunc(ImmutableCallSite CS, LibFunc &F) const {
|
||||
return !CS.isNoBuiltin() && CS.getCalledFunction() &&
|
||||
getLibFunc(*(CS.getCalledFunction()), F);
|
||||
}
|
||||
|
||||
/// Tests whether a library function is available.
|
||||
bool has(LibFunc F) const {
|
||||
return Impl->getState(F) != TargetLibraryInfoImpl::Unavailable;
|
||||
|
@ -267,6 +267,19 @@ class TargetTransformInfo {
|
||||
/// incurs significant execution cost.
|
||||
bool isLoweredToCall(const Function *F) const;
|
||||
|
||||
struct LSRCost {
|
||||
/// TODO: Some of these could be merged. Also, a lexical ordering
|
||||
/// isn't always optimal.
|
||||
unsigned Insns;
|
||||
unsigned NumRegs;
|
||||
unsigned AddRecCost;
|
||||
unsigned NumIVMuls;
|
||||
unsigned NumBaseAdds;
|
||||
unsigned ImmCost;
|
||||
unsigned SetupCost;
|
||||
unsigned ScaleCost;
|
||||
};
|
||||
|
||||
/// Parameters that control the generic loop unrolling transformation.
|
||||
struct UnrollingPreferences {
|
||||
/// The cost threshold for the unrolled loop. Should be relative to the
|
||||
@ -385,6 +398,10 @@ class TargetTransformInfo {
|
||||
bool HasBaseReg, int64_t Scale,
|
||||
unsigned AddrSpace = 0) const;
|
||||
|
||||
/// \brief Return true if LSR cost of C1 is lower than C1.
|
||||
bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
|
||||
TargetTransformInfo::LSRCost &C2) const;
|
||||
|
||||
/// \brief Return true if the target supports masked load/store
|
||||
/// AVX2 and AVX-512 targets allow masks for consecutive load and store
|
||||
bool isLegalMaskedStore(Type *DataType) const;
|
||||
@ -705,6 +722,10 @@ class TargetTransformInfo {
|
||||
/// if false is returned.
|
||||
bool getTgtMemIntrinsic(IntrinsicInst *Inst, MemIntrinsicInfo &Info) const;
|
||||
|
||||
/// \returns The maximum element size, in bytes, for an element
|
||||
/// unordered-atomic memory intrinsic.
|
||||
unsigned getAtomicMemIntrinsicMaxElementSize() const;
|
||||
|
||||
/// \returns A value which is the result of the given memory intrinsic. New
|
||||
/// instructions may be created to extract the result from the given intrinsic
|
||||
/// memory operation. Returns nullptr if the target cannot create a result
|
||||
@ -809,6 +830,8 @@ class TargetTransformInfo::Concept {
|
||||
int64_t BaseOffset, bool HasBaseReg,
|
||||
int64_t Scale,
|
||||
unsigned AddrSpace) = 0;
|
||||
virtual bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
|
||||
TargetTransformInfo::LSRCost &C2) = 0;
|
||||
virtual bool isLegalMaskedStore(Type *DataType) = 0;
|
||||
virtual bool isLegalMaskedLoad(Type *DataType) = 0;
|
||||
virtual bool isLegalMaskedScatter(Type *DataType) = 0;
|
||||
@ -904,6 +927,7 @@ class TargetTransformInfo::Concept {
|
||||
virtual unsigned getCostOfKeepingLiveOverCall(ArrayRef<Type *> Tys) = 0;
|
||||
virtual bool getTgtMemIntrinsic(IntrinsicInst *Inst,
|
||||
MemIntrinsicInfo &Info) = 0;
|
||||
virtual unsigned getAtomicMemIntrinsicMaxElementSize() const = 0;
|
||||
virtual Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
|
||||
Type *ExpectedType) = 0;
|
||||
virtual bool areInlineCompatible(const Function *Caller,
|
||||
@ -996,6 +1020,10 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
|
||||
return Impl.isLegalAddressingMode(Ty, BaseGV, BaseOffset, HasBaseReg,
|
||||
Scale, AddrSpace);
|
||||
}
|
||||
bool isLSRCostLess(TargetTransformInfo::LSRCost &C1,
|
||||
TargetTransformInfo::LSRCost &C2) override {
|
||||
return Impl.isLSRCostLess(C1, C2);
|
||||
}
|
||||
bool isLegalMaskedStore(Type *DataType) override {
|
||||
return Impl.isLegalMaskedStore(DataType);
|
||||
}
|
||||
@ -1201,6 +1229,9 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
|
||||
MemIntrinsicInfo &Info) override {
|
||||
return Impl.getTgtMemIntrinsic(Inst, Info);
|
||||
}
|
||||
unsigned getAtomicMemIntrinsicMaxElementSize() const override {
|
||||
return Impl.getAtomicMemIntrinsicMaxElementSize();
|
||||
}
|
||||
Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
|
||||
Type *ExpectedType) override {
|
||||
return Impl.getOrCreateResultFromMemIntrinsic(Inst, ExpectedType);
|
||||
|
@ -17,13 +17,13 @@
|
||||
|
||||
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
|
||||
#include "llvm/Analysis/TargetTransformInfo.h"
|
||||
#include "llvm/Analysis/VectorUtils.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/DataLayout.h"
|
||||
#include "llvm/IR/Function.h"
|
||||
#include "llvm/IR/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/IR/Operator.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/Analysis/VectorUtils.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -229,6 +229,13 @@ class TargetTransformInfoImplBase {
|
||||
return !BaseGV && BaseOffset == 0 && (Scale == 0 || Scale == 1);
|
||||
}
|
||||
|
||||
bool isLSRCostLess(TTI::LSRCost &C1, TTI::LSRCost &C2) {
|
||||
return std::tie(C1.NumRegs, C1.AddRecCost, C1.NumIVMuls, C1.NumBaseAdds,
|
||||
C1.ScaleCost, C1.ImmCost, C1.SetupCost) <
|
||||
std::tie(C2.NumRegs, C2.AddRecCost, C2.NumIVMuls, C2.NumBaseAdds,
|
||||
C2.ScaleCost, C2.ImmCost, C2.SetupCost);
|
||||
}
|
||||
|
||||
bool isLegalMaskedStore(Type *DataType) { return false; }
|
||||
|
||||
bool isLegalMaskedLoad(Type *DataType) { return false; }
|
||||
@ -420,6 +427,15 @@ class TargetTransformInfoImplBase {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned getAtomicMemIntrinsicMaxElementSize() const {
|
||||
// Note for overrides: You must ensure for all element unordered-atomic
|
||||
// memory intrinsics that all power-of-2 element sizes up to, and
|
||||
// including, the return value of this method have a corresponding
|
||||
// runtime lib call. These runtime lib call definitions can be found
|
||||
// in RuntimeLibcalls.h
|
||||
return 0;
|
||||
}
|
||||
|
||||
Value *getOrCreateResultFromMemIntrinsic(IntrinsicInst *Inst,
|
||||
Type *ExpectedType) {
|
||||
return nullptr;
|
||||
|
713
include/llvm/BinaryFormat/COFF.h
Normal file
713
include/llvm/BinaryFormat/COFF.h
Normal file
@ -0,0 +1,713 @@
|
||||
//===-- llvm/BinaryFormat/COFF.h --------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file contains an definitions used in Windows COFF Files.
|
||||
//
|
||||
// Structures and enums defined within this file where created using
|
||||
// information from Microsoft's publicly available PE/COFF format document:
|
||||
//
|
||||
// Microsoft Portable Executable and Common Object File Format Specification
|
||||
// Revision 8.1 - February 15, 2008
|
||||
//
|
||||
// As of 5/2/2010, hosted by Microsoft at:
|
||||
// http://www.microsoft.com/whdc/system/platform/firmware/pecoff.mspx
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_BINARYFORMAT_COFF_H
|
||||
#define LLVM_BINARYFORMAT_COFF_H
|
||||
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
namespace llvm {
|
||||
namespace COFF {
|
||||
|
||||
// The maximum number of sections that a COFF object can have (inclusive).
|
||||
const int32_t MaxNumberOfSections16 = 65279;
|
||||
|
||||
// The PE signature bytes that follows the DOS stub header.
|
||||
static const char PEMagic[] = {'P', 'E', '\0', '\0'};
|
||||
|
||||
static const char BigObjMagic[] = {
|
||||
'\xc7', '\xa1', '\xba', '\xd1', '\xee', '\xba', '\xa9', '\x4b',
|
||||
'\xaf', '\x20', '\xfa', '\xf6', '\x6a', '\xa4', '\xdc', '\xb8',
|
||||
};
|
||||
|
||||
static const char ClGlObjMagic[] = {
|
||||
'\x38', '\xfe', '\xb3', '\x0c', '\xa5', '\xd9', '\xab', '\x4d',
|
||||
'\xac', '\x9b', '\xd6', '\xb6', '\x22', '\x26', '\x53', '\xc2',
|
||||
};
|
||||
|
||||
// Sizes in bytes of various things in the COFF format.
|
||||
enum {
|
||||
Header16Size = 20,
|
||||
Header32Size = 56,
|
||||
NameSize = 8,
|
||||
Symbol16Size = 18,
|
||||
Symbol32Size = 20,
|
||||
SectionSize = 40,
|
||||
RelocationSize = 10
|
||||
};
|
||||
|
||||
struct header {
|
||||
uint16_t Machine;
|
||||
int32_t NumberOfSections;
|
||||
uint32_t TimeDateStamp;
|
||||
uint32_t PointerToSymbolTable;
|
||||
uint32_t NumberOfSymbols;
|
||||
uint16_t SizeOfOptionalHeader;
|
||||
uint16_t Characteristics;
|
||||
};
|
||||
|
||||
struct BigObjHeader {
|
||||
enum : uint16_t { MinBigObjectVersion = 2 };
|
||||
|
||||
uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0).
|
||||
uint16_t Sig2; ///< Must be 0xFFFF.
|
||||
uint16_t Version;
|
||||
uint16_t Machine;
|
||||
uint32_t TimeDateStamp;
|
||||
uint8_t UUID[16];
|
||||
uint32_t unused1;
|
||||
uint32_t unused2;
|
||||
uint32_t unused3;
|
||||
uint32_t unused4;
|
||||
uint32_t NumberOfSections;
|
||||
uint32_t PointerToSymbolTable;
|
||||
uint32_t NumberOfSymbols;
|
||||
};
|
||||
|
||||
enum MachineTypes {
|
||||
MT_Invalid = 0xffff,
|
||||
|
||||
IMAGE_FILE_MACHINE_UNKNOWN = 0x0,
|
||||
IMAGE_FILE_MACHINE_AM33 = 0x13,
|
||||
IMAGE_FILE_MACHINE_AMD64 = 0x8664,
|
||||
IMAGE_FILE_MACHINE_ARM = 0x1C0,
|
||||
IMAGE_FILE_MACHINE_ARMNT = 0x1C4,
|
||||
IMAGE_FILE_MACHINE_ARM64 = 0xAA64,
|
||||
IMAGE_FILE_MACHINE_EBC = 0xEBC,
|
||||
IMAGE_FILE_MACHINE_I386 = 0x14C,
|
||||
IMAGE_FILE_MACHINE_IA64 = 0x200,
|
||||
IMAGE_FILE_MACHINE_M32R = 0x9041,
|
||||
IMAGE_FILE_MACHINE_MIPS16 = 0x266,
|
||||
IMAGE_FILE_MACHINE_MIPSFPU = 0x366,
|
||||
IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466,
|
||||
IMAGE_FILE_MACHINE_POWERPC = 0x1F0,
|
||||
IMAGE_FILE_MACHINE_POWERPCFP = 0x1F1,
|
||||
IMAGE_FILE_MACHINE_R4000 = 0x166,
|
||||
IMAGE_FILE_MACHINE_SH3 = 0x1A2,
|
||||
IMAGE_FILE_MACHINE_SH3DSP = 0x1A3,
|
||||
IMAGE_FILE_MACHINE_SH4 = 0x1A6,
|
||||
IMAGE_FILE_MACHINE_SH5 = 0x1A8,
|
||||
IMAGE_FILE_MACHINE_THUMB = 0x1C2,
|
||||
IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169
|
||||
};
|
||||
|
||||
enum Characteristics {
|
||||
C_Invalid = 0,
|
||||
|
||||
/// The file does not contain base relocations and must be loaded at its
|
||||
/// preferred base. If this cannot be done, the loader will error.
|
||||
IMAGE_FILE_RELOCS_STRIPPED = 0x0001,
|
||||
/// The file is valid and can be run.
|
||||
IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002,
|
||||
/// COFF line numbers have been stripped. This is deprecated and should be
|
||||
/// 0.
|
||||
IMAGE_FILE_LINE_NUMS_STRIPPED = 0x0004,
|
||||
/// COFF symbol table entries for local symbols have been removed. This is
|
||||
/// deprecated and should be 0.
|
||||
IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x0008,
|
||||
/// Aggressively trim working set. This is deprecated and must be 0.
|
||||
IMAGE_FILE_AGGRESSIVE_WS_TRIM = 0x0010,
|
||||
/// Image can handle > 2GiB addresses.
|
||||
IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020,
|
||||
/// Little endian: the LSB precedes the MSB in memory. This is deprecated
|
||||
/// and should be 0.
|
||||
IMAGE_FILE_BYTES_REVERSED_LO = 0x0080,
|
||||
/// Machine is based on a 32bit word architecture.
|
||||
IMAGE_FILE_32BIT_MACHINE = 0x0100,
|
||||
/// Debugging info has been removed.
|
||||
IMAGE_FILE_DEBUG_STRIPPED = 0x0200,
|
||||
/// If the image is on removable media, fully load it and copy it to swap.
|
||||
IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400,
|
||||
/// If the image is on network media, fully load it and copy it to swap.
|
||||
IMAGE_FILE_NET_RUN_FROM_SWAP = 0x0800,
|
||||
/// The image file is a system file, not a user program.
|
||||
IMAGE_FILE_SYSTEM = 0x1000,
|
||||
/// The image file is a DLL.
|
||||
IMAGE_FILE_DLL = 0x2000,
|
||||
/// This file should only be run on a uniprocessor machine.
|
||||
IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000,
|
||||
/// Big endian: the MSB precedes the LSB in memory. This is deprecated
|
||||
/// and should be 0.
|
||||
IMAGE_FILE_BYTES_REVERSED_HI = 0x8000
|
||||
};
|
||||
|
||||
enum ResourceTypeID {
|
||||
RID_Cursor = 1,
|
||||
RID_Bitmap = 2,
|
||||
RID_Icon = 3,
|
||||
RID_Menu = 4,
|
||||
RID_Dialog = 5,
|
||||
RID_String = 6,
|
||||
RID_FontDir = 7,
|
||||
RID_Font = 8,
|
||||
RID_Accelerator = 9,
|
||||
RID_RCData = 10,
|
||||
RID_MessageTable = 11,
|
||||
RID_Group_Cursor = 12,
|
||||
RID_Group_Icon = 14,
|
||||
RID_Version = 16,
|
||||
RID_DLGInclude = 17,
|
||||
RID_PlugPlay = 19,
|
||||
RID_VXD = 20,
|
||||
RID_AniCursor = 21,
|
||||
RID_AniIcon = 22,
|
||||
RID_HTML = 23,
|
||||
RID_Manifest = 24,
|
||||
};
|
||||
|
||||
struct symbol {
|
||||
char Name[NameSize];
|
||||
uint32_t Value;
|
||||
int32_t SectionNumber;
|
||||
uint16_t Type;
|
||||
uint8_t StorageClass;
|
||||
uint8_t NumberOfAuxSymbols;
|
||||
};
|
||||
|
||||
enum SymbolSectionNumber : int32_t {
|
||||
IMAGE_SYM_DEBUG = -2,
|
||||
IMAGE_SYM_ABSOLUTE = -1,
|
||||
IMAGE_SYM_UNDEFINED = 0
|
||||
};
|
||||
|
||||
/// Storage class tells where and what the symbol represents
|
||||
enum SymbolStorageClass {
|
||||
SSC_Invalid = 0xff,
|
||||
|
||||
IMAGE_SYM_CLASS_END_OF_FUNCTION = -1, ///< Physical end of function
|
||||
IMAGE_SYM_CLASS_NULL = 0, ///< No symbol
|
||||
IMAGE_SYM_CLASS_AUTOMATIC = 1, ///< Stack variable
|
||||
IMAGE_SYM_CLASS_EXTERNAL = 2, ///< External symbol
|
||||
IMAGE_SYM_CLASS_STATIC = 3, ///< Static
|
||||
IMAGE_SYM_CLASS_REGISTER = 4, ///< Register variable
|
||||
IMAGE_SYM_CLASS_EXTERNAL_DEF = 5, ///< External definition
|
||||
IMAGE_SYM_CLASS_LABEL = 6, ///< Label
|
||||
IMAGE_SYM_CLASS_UNDEFINED_LABEL = 7, ///< Undefined label
|
||||
IMAGE_SYM_CLASS_MEMBER_OF_STRUCT = 8, ///< Member of structure
|
||||
IMAGE_SYM_CLASS_ARGUMENT = 9, ///< Function argument
|
||||
IMAGE_SYM_CLASS_STRUCT_TAG = 10, ///< Structure tag
|
||||
IMAGE_SYM_CLASS_MEMBER_OF_UNION = 11, ///< Member of union
|
||||
IMAGE_SYM_CLASS_UNION_TAG = 12, ///< Union tag
|
||||
IMAGE_SYM_CLASS_TYPE_DEFINITION = 13, ///< Type definition
|
||||
IMAGE_SYM_CLASS_UNDEFINED_STATIC = 14, ///< Undefined static
|
||||
IMAGE_SYM_CLASS_ENUM_TAG = 15, ///< Enumeration tag
|
||||
IMAGE_SYM_CLASS_MEMBER_OF_ENUM = 16, ///< Member of enumeration
|
||||
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,
|
||||
/// ".bf" or ".ef" - beginning or end of function
|
||||
IMAGE_SYM_CLASS_FUNCTION = 101,
|
||||
IMAGE_SYM_CLASS_END_OF_STRUCT = 102, ///< End of structure
|
||||
IMAGE_SYM_CLASS_FILE = 103, ///< File name
|
||||
/// Line number, reformatted as symbol
|
||||
IMAGE_SYM_CLASS_SECTION = 104,
|
||||
IMAGE_SYM_CLASS_WEAK_EXTERNAL = 105, ///< Duplicate tag
|
||||
/// External symbol in dmert public lib
|
||||
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
|
||||
};
|
||||
|
||||
enum AuxSymbolType { IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1 };
|
||||
|
||||
struct section {
|
||||
char Name[NameSize];
|
||||
uint32_t VirtualSize;
|
||||
uint32_t VirtualAddress;
|
||||
uint32_t SizeOfRawData;
|
||||
uint32_t PointerToRawData;
|
||||
uint32_t PointerToRelocations;
|
||||
uint32_t PointerToLineNumbers;
|
||||
uint16_t NumberOfRelocations;
|
||||
uint16_t NumberOfLineNumbers;
|
||||
uint32_t Characteristics;
|
||||
};
|
||||
|
||||
enum SectionCharacteristics : uint32_t {
|
||||
SC_Invalid = 0xffffffff,
|
||||
|
||||
IMAGE_SCN_TYPE_NOLOAD = 0x00000002,
|
||||
IMAGE_SCN_TYPE_NO_PAD = 0x00000008,
|
||||
IMAGE_SCN_CNT_CODE = 0x00000020,
|
||||
IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040,
|
||||
IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080,
|
||||
IMAGE_SCN_LNK_OTHER = 0x00000100,
|
||||
IMAGE_SCN_LNK_INFO = 0x00000200,
|
||||
IMAGE_SCN_LNK_REMOVE = 0x00000800,
|
||||
IMAGE_SCN_LNK_COMDAT = 0x00001000,
|
||||
IMAGE_SCN_GPREL = 0x00008000,
|
||||
IMAGE_SCN_MEM_PURGEABLE = 0x00020000,
|
||||
IMAGE_SCN_MEM_16BIT = 0x00020000,
|
||||
IMAGE_SCN_MEM_LOCKED = 0x00040000,
|
||||
IMAGE_SCN_MEM_PRELOAD = 0x00080000,
|
||||
IMAGE_SCN_ALIGN_1BYTES = 0x00100000,
|
||||
IMAGE_SCN_ALIGN_2BYTES = 0x00200000,
|
||||
IMAGE_SCN_ALIGN_4BYTES = 0x00300000,
|
||||
IMAGE_SCN_ALIGN_8BYTES = 0x00400000,
|
||||
IMAGE_SCN_ALIGN_16BYTES = 0x00500000,
|
||||
IMAGE_SCN_ALIGN_32BYTES = 0x00600000,
|
||||
IMAGE_SCN_ALIGN_64BYTES = 0x00700000,
|
||||
IMAGE_SCN_ALIGN_128BYTES = 0x00800000,
|
||||
IMAGE_SCN_ALIGN_256BYTES = 0x00900000,
|
||||
IMAGE_SCN_ALIGN_512BYTES = 0x00A00000,
|
||||
IMAGE_SCN_ALIGN_1024BYTES = 0x00B00000,
|
||||
IMAGE_SCN_ALIGN_2048BYTES = 0x00C00000,
|
||||
IMAGE_SCN_ALIGN_4096BYTES = 0x00D00000,
|
||||
IMAGE_SCN_ALIGN_8192BYTES = 0x00E00000,
|
||||
IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000,
|
||||
IMAGE_SCN_MEM_DISCARDABLE = 0x02000000,
|
||||
IMAGE_SCN_MEM_NOT_CACHED = 0x04000000,
|
||||
IMAGE_SCN_MEM_NOT_PAGED = 0x08000000,
|
||||
IMAGE_SCN_MEM_SHARED = 0x10000000,
|
||||
IMAGE_SCN_MEM_EXECUTE = 0x20000000,
|
||||
IMAGE_SCN_MEM_READ = 0x40000000,
|
||||
IMAGE_SCN_MEM_WRITE = 0x80000000
|
||||
};
|
||||
|
||||
struct relocation {
|
||||
uint32_t VirtualAddress;
|
||||
uint32_t SymbolTableIndex;
|
||||
uint16_t Type;
|
||||
};
|
||||
|
||||
enum RelocationTypeI386 {
|
||||
IMAGE_REL_I386_ABSOLUTE = 0x0000,
|
||||
IMAGE_REL_I386_DIR16 = 0x0001,
|
||||
IMAGE_REL_I386_REL16 = 0x0002,
|
||||
IMAGE_REL_I386_DIR32 = 0x0006,
|
||||
IMAGE_REL_I386_DIR32NB = 0x0007,
|
||||
IMAGE_REL_I386_SEG12 = 0x0009,
|
||||
IMAGE_REL_I386_SECTION = 0x000A,
|
||||
IMAGE_REL_I386_SECREL = 0x000B,
|
||||
IMAGE_REL_I386_TOKEN = 0x000C,
|
||||
IMAGE_REL_I386_SECREL7 = 0x000D,
|
||||
IMAGE_REL_I386_REL32 = 0x0014
|
||||
};
|
||||
|
||||
enum RelocationTypeAMD64 {
|
||||
IMAGE_REL_AMD64_ABSOLUTE = 0x0000,
|
||||
IMAGE_REL_AMD64_ADDR64 = 0x0001,
|
||||
IMAGE_REL_AMD64_ADDR32 = 0x0002,
|
||||
IMAGE_REL_AMD64_ADDR32NB = 0x0003,
|
||||
IMAGE_REL_AMD64_REL32 = 0x0004,
|
||||
IMAGE_REL_AMD64_REL32_1 = 0x0005,
|
||||
IMAGE_REL_AMD64_REL32_2 = 0x0006,
|
||||
IMAGE_REL_AMD64_REL32_3 = 0x0007,
|
||||
IMAGE_REL_AMD64_REL32_4 = 0x0008,
|
||||
IMAGE_REL_AMD64_REL32_5 = 0x0009,
|
||||
IMAGE_REL_AMD64_SECTION = 0x000A,
|
||||
IMAGE_REL_AMD64_SECREL = 0x000B,
|
||||
IMAGE_REL_AMD64_SECREL7 = 0x000C,
|
||||
IMAGE_REL_AMD64_TOKEN = 0x000D,
|
||||
IMAGE_REL_AMD64_SREL32 = 0x000E,
|
||||
IMAGE_REL_AMD64_PAIR = 0x000F,
|
||||
IMAGE_REL_AMD64_SSPAN32 = 0x0010
|
||||
};
|
||||
|
||||
enum RelocationTypesARM {
|
||||
IMAGE_REL_ARM_ABSOLUTE = 0x0000,
|
||||
IMAGE_REL_ARM_ADDR32 = 0x0001,
|
||||
IMAGE_REL_ARM_ADDR32NB = 0x0002,
|
||||
IMAGE_REL_ARM_BRANCH24 = 0x0003,
|
||||
IMAGE_REL_ARM_BRANCH11 = 0x0004,
|
||||
IMAGE_REL_ARM_TOKEN = 0x0005,
|
||||
IMAGE_REL_ARM_BLX24 = 0x0008,
|
||||
IMAGE_REL_ARM_BLX11 = 0x0009,
|
||||
IMAGE_REL_ARM_SECTION = 0x000E,
|
||||
IMAGE_REL_ARM_SECREL = 0x000F,
|
||||
IMAGE_REL_ARM_MOV32A = 0x0010,
|
||||
IMAGE_REL_ARM_MOV32T = 0x0011,
|
||||
IMAGE_REL_ARM_BRANCH20T = 0x0012,
|
||||
IMAGE_REL_ARM_BRANCH24T = 0x0014,
|
||||
IMAGE_REL_ARM_BLX23T = 0x0015
|
||||
};
|
||||
|
||||
enum RelocationTypesARM64 {
|
||||
IMAGE_REL_ARM64_ABSOLUTE = 0x0000,
|
||||
IMAGE_REL_ARM64_ADDR32 = 0x0001,
|
||||
IMAGE_REL_ARM64_ADDR32NB = 0x0002,
|
||||
IMAGE_REL_ARM64_BRANCH26 = 0x0003,
|
||||
IMAGE_REL_ARM64_PAGEBASE_REL2 = 0x0004,
|
||||
IMAGE_REL_ARM64_REL21 = 0x0005,
|
||||
IMAGE_REL_ARM64_PAGEOFFSET_12A = 0x0006,
|
||||
IMAGE_REL_ARM64_PAGEOFFSET_12L = 0x0007,
|
||||
IMAGE_REL_ARM64_SECREL = 0x0008,
|
||||
IMAGE_REL_ARM64_SECREL_LOW12A = 0x0009,
|
||||
IMAGE_REL_ARM64_SECREL_HIGH12A = 0x000A,
|
||||
IMAGE_REL_ARM64_SECREL_LOW12L = 0x000B,
|
||||
IMAGE_REL_ARM64_TOKEN = 0x000C,
|
||||
IMAGE_REL_ARM64_SECTION = 0x000D,
|
||||
IMAGE_REL_ARM64_ADDR64 = 0x000E,
|
||||
IMAGE_REL_ARM64_BRANCH19 = 0x000F,
|
||||
IMAGE_REL_ARM64_BRANCH14 = 0x0010,
|
||||
};
|
||||
|
||||
enum COMDATType {
|
||||
IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
|
||||
IMAGE_COMDAT_SELECT_ANY,
|
||||
IMAGE_COMDAT_SELECT_SAME_SIZE,
|
||||
IMAGE_COMDAT_SELECT_EXACT_MATCH,
|
||||
IMAGE_COMDAT_SELECT_ASSOCIATIVE,
|
||||
IMAGE_COMDAT_SELECT_LARGEST,
|
||||
IMAGE_COMDAT_SELECT_NEWEST
|
||||
};
|
||||
|
||||
// Auxiliary Symbol Formats
|
||||
struct AuxiliaryFunctionDefinition {
|
||||
uint32_t TagIndex;
|
||||
uint32_t TotalSize;
|
||||
uint32_t PointerToLinenumber;
|
||||
uint32_t PointerToNextFunction;
|
||||
char unused[2];
|
||||
};
|
||||
|
||||
struct AuxiliarybfAndefSymbol {
|
||||
uint8_t unused1[4];
|
||||
uint16_t Linenumber;
|
||||
uint8_t unused2[6];
|
||||
uint32_t PointerToNextFunction;
|
||||
uint8_t unused3[2];
|
||||
};
|
||||
|
||||
struct AuxiliaryWeakExternal {
|
||||
uint32_t TagIndex;
|
||||
uint32_t Characteristics;
|
||||
uint8_t unused[10];
|
||||
};
|
||||
|
||||
enum WeakExternalCharacteristics {
|
||||
IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1,
|
||||
IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2,
|
||||
IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3
|
||||
};
|
||||
|
||||
struct AuxiliarySectionDefinition {
|
||||
uint32_t Length;
|
||||
uint16_t NumberOfRelocations;
|
||||
uint16_t NumberOfLinenumbers;
|
||||
uint32_t CheckSum;
|
||||
uint32_t Number;
|
||||
uint8_t Selection;
|
||||
char unused;
|
||||
};
|
||||
|
||||
struct AuxiliaryCLRToken {
|
||||
uint8_t AuxType;
|
||||
uint8_t unused1;
|
||||
uint32_t SymbolTableIndex;
|
||||
char unused2[12];
|
||||
};
|
||||
|
||||
union Auxiliary {
|
||||
AuxiliaryFunctionDefinition FunctionDefinition;
|
||||
AuxiliarybfAndefSymbol bfAndefSymbol;
|
||||
AuxiliaryWeakExternal WeakExternal;
|
||||
AuxiliarySectionDefinition SectionDefinition;
|
||||
};
|
||||
|
||||
/// @brief The Import Directory Table.
|
||||
///
|
||||
/// There is a single array of these and one entry per imported DLL.
|
||||
struct ImportDirectoryTableEntry {
|
||||
uint32_t ImportLookupTableRVA;
|
||||
uint32_t TimeDateStamp;
|
||||
uint32_t ForwarderChain;
|
||||
uint32_t NameRVA;
|
||||
uint32_t ImportAddressTableRVA;
|
||||
};
|
||||
|
||||
/// @brief The PE32 Import Lookup Table.
|
||||
///
|
||||
/// There is an array of these for each imported DLL. It represents either
|
||||
/// the ordinal to import from the target DLL, or a name to lookup and import
|
||||
/// from the target DLL.
|
||||
///
|
||||
/// This also happens to be the same format used by the Import Address Table
|
||||
/// when it is initially written out to the image.
|
||||
struct ImportLookupTableEntry32 {
|
||||
uint32_t data;
|
||||
|
||||
/// @brief Is this entry specified by ordinal, or name?
|
||||
bool isOrdinal() const { return data & 0x80000000; }
|
||||
|
||||
/// @brief Get the ordinal value of this entry. isOrdinal must be true.
|
||||
uint16_t getOrdinal() const {
|
||||
assert(isOrdinal() && "ILT entry is not an ordinal!");
|
||||
return data & 0xFFFF;
|
||||
}
|
||||
|
||||
/// @brief Set the ordinal value and set isOrdinal to true.
|
||||
void setOrdinal(uint16_t o) {
|
||||
data = o;
|
||||
data |= 0x80000000;
|
||||
}
|
||||
|
||||
/// @brief Get the Hint/Name entry RVA. isOrdinal must be false.
|
||||
uint32_t getHintNameRVA() const {
|
||||
assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!");
|
||||
return data;
|
||||
}
|
||||
|
||||
/// @brief Set the Hint/Name entry RVA and set isOrdinal to false.
|
||||
void setHintNameRVA(uint32_t rva) { data = rva; }
|
||||
};
|
||||
|
||||
/// @brief The DOS compatible header at the front of all PEs.
|
||||
struct DOSHeader {
|
||||
uint16_t Magic;
|
||||
uint16_t UsedBytesInTheLastPage;
|
||||
uint16_t FileSizeInPages;
|
||||
uint16_t NumberOfRelocationItems;
|
||||
uint16_t HeaderSizeInParagraphs;
|
||||
uint16_t MinimumExtraParagraphs;
|
||||
uint16_t MaximumExtraParagraphs;
|
||||
uint16_t InitialRelativeSS;
|
||||
uint16_t InitialSP;
|
||||
uint16_t Checksum;
|
||||
uint16_t InitialIP;
|
||||
uint16_t InitialRelativeCS;
|
||||
uint16_t AddressOfRelocationTable;
|
||||
uint16_t OverlayNumber;
|
||||
uint16_t Reserved[4];
|
||||
uint16_t OEMid;
|
||||
uint16_t OEMinfo;
|
||||
uint16_t Reserved2[10];
|
||||
uint32_t AddressOfNewExeHeader;
|
||||
};
|
||||
|
||||
struct PE32Header {
|
||||
enum { PE32 = 0x10b, PE32_PLUS = 0x20b };
|
||||
|
||||
uint16_t Magic;
|
||||
uint8_t MajorLinkerVersion;
|
||||
uint8_t MinorLinkerVersion;
|
||||
uint32_t SizeOfCode;
|
||||
uint32_t SizeOfInitializedData;
|
||||
uint32_t SizeOfUninitializedData;
|
||||
uint32_t AddressOfEntryPoint; // RVA
|
||||
uint32_t BaseOfCode; // RVA
|
||||
uint32_t BaseOfData; // RVA
|
||||
uint32_t ImageBase;
|
||||
uint32_t SectionAlignment;
|
||||
uint32_t FileAlignment;
|
||||
uint16_t MajorOperatingSystemVersion;
|
||||
uint16_t MinorOperatingSystemVersion;
|
||||
uint16_t MajorImageVersion;
|
||||
uint16_t MinorImageVersion;
|
||||
uint16_t MajorSubsystemVersion;
|
||||
uint16_t MinorSubsystemVersion;
|
||||
uint32_t Win32VersionValue;
|
||||
uint32_t SizeOfImage;
|
||||
uint32_t SizeOfHeaders;
|
||||
uint32_t CheckSum;
|
||||
uint16_t Subsystem;
|
||||
// FIXME: This should be DllCharacteristics to match the COFF spec.
|
||||
uint16_t DLLCharacteristics;
|
||||
uint32_t SizeOfStackReserve;
|
||||
uint32_t SizeOfStackCommit;
|
||||
uint32_t SizeOfHeapReserve;
|
||||
uint32_t SizeOfHeapCommit;
|
||||
uint32_t LoaderFlags;
|
||||
// FIXME: This should be NumberOfRvaAndSizes to match the COFF spec.
|
||||
uint32_t NumberOfRvaAndSize;
|
||||
};
|
||||
|
||||
struct DataDirectory {
|
||||
uint32_t RelativeVirtualAddress;
|
||||
uint32_t Size;
|
||||
};
|
||||
|
||||
enum DataDirectoryIndex {
|
||||
EXPORT_TABLE = 0,
|
||||
IMPORT_TABLE,
|
||||
RESOURCE_TABLE,
|
||||
EXCEPTION_TABLE,
|
||||
CERTIFICATE_TABLE,
|
||||
BASE_RELOCATION_TABLE,
|
||||
DEBUG_DIRECTORY,
|
||||
ARCHITECTURE,
|
||||
GLOBAL_PTR,
|
||||
TLS_TABLE,
|
||||
LOAD_CONFIG_TABLE,
|
||||
BOUND_IMPORT,
|
||||
IAT,
|
||||
DELAY_IMPORT_DESCRIPTOR,
|
||||
CLR_RUNTIME_HEADER,
|
||||
|
||||
NUM_DATA_DIRECTORIES
|
||||
};
|
||||
|
||||
enum WindowsSubsystem {
|
||||
IMAGE_SUBSYSTEM_UNKNOWN = 0, ///< An unknown subsystem.
|
||||
IMAGE_SUBSYSTEM_NATIVE = 1, ///< Device drivers and native Windows processes
|
||||
IMAGE_SUBSYSTEM_WINDOWS_GUI = 2, ///< The Windows GUI subsystem.
|
||||
IMAGE_SUBSYSTEM_WINDOWS_CUI = 3, ///< The Windows character subsystem.
|
||||
IMAGE_SUBSYSTEM_OS2_CUI = 5, ///< The OS/2 character subsytem.
|
||||
IMAGE_SUBSYSTEM_POSIX_CUI = 7, ///< The POSIX character subsystem.
|
||||
IMAGE_SUBSYSTEM_NATIVE_WINDOWS = 8, ///< Native Windows 9x driver.
|
||||
IMAGE_SUBSYSTEM_WINDOWS_CE_GUI = 9, ///< Windows CE.
|
||||
IMAGE_SUBSYSTEM_EFI_APPLICATION = 10, ///< An EFI application.
|
||||
IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, ///< An EFI driver with boot
|
||||
/// services.
|
||||
IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, ///< An EFI driver with run-time
|
||||
/// services.
|
||||
IMAGE_SUBSYSTEM_EFI_ROM = 13, ///< An EFI ROM image.
|
||||
IMAGE_SUBSYSTEM_XBOX = 14, ///< XBOX.
|
||||
IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application.
|
||||
};
|
||||
|
||||
enum DLLCharacteristics {
|
||||
/// ASLR with 64 bit address space.
|
||||
IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020,
|
||||
/// DLL can be relocated at load time.
|
||||
IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040,
|
||||
/// Code integrity checks are enforced.
|
||||
IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080,
|
||||
///< Image is NX compatible.
|
||||
IMAGE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100,
|
||||
/// Isolation aware, but do not isolate the image.
|
||||
IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION = 0x0200,
|
||||
/// Does not use structured exception handling (SEH). No SEH handler may be
|
||||
/// called in this image.
|
||||
IMAGE_DLL_CHARACTERISTICS_NO_SEH = 0x0400,
|
||||
/// Do not bind the image.
|
||||
IMAGE_DLL_CHARACTERISTICS_NO_BIND = 0x0800,
|
||||
///< Image should execute in an AppContainer.
|
||||
IMAGE_DLL_CHARACTERISTICS_APPCONTAINER = 0x1000,
|
||||
///< A WDM driver.
|
||||
IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER = 0x2000,
|
||||
///< Image supports Control Flow Guard.
|
||||
IMAGE_DLL_CHARACTERISTICS_GUARD_CF = 0x4000,
|
||||
/// Terminal Server aware.
|
||||
IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000
|
||||
};
|
||||
|
||||
enum DebugType {
|
||||
IMAGE_DEBUG_TYPE_UNKNOWN = 0,
|
||||
IMAGE_DEBUG_TYPE_COFF = 1,
|
||||
IMAGE_DEBUG_TYPE_CODEVIEW = 2,
|
||||
IMAGE_DEBUG_TYPE_FPO = 3,
|
||||
IMAGE_DEBUG_TYPE_MISC = 4,
|
||||
IMAGE_DEBUG_TYPE_EXCEPTION = 5,
|
||||
IMAGE_DEBUG_TYPE_FIXUP = 6,
|
||||
IMAGE_DEBUG_TYPE_OMAP_TO_SRC = 7,
|
||||
IMAGE_DEBUG_TYPE_OMAP_FROM_SRC = 8,
|
||||
IMAGE_DEBUG_TYPE_BORLAND = 9,
|
||||
IMAGE_DEBUG_TYPE_RESERVED10 = 10,
|
||||
IMAGE_DEBUG_TYPE_CLSID = 11,
|
||||
IMAGE_DEBUG_TYPE_VC_FEATURE = 12,
|
||||
IMAGE_DEBUG_TYPE_POGO = 13,
|
||||
IMAGE_DEBUG_TYPE_ILTCG = 14,
|
||||
IMAGE_DEBUG_TYPE_MPX = 15,
|
||||
IMAGE_DEBUG_TYPE_REPRO = 16,
|
||||
};
|
||||
|
||||
enum BaseRelocationType {
|
||||
IMAGE_REL_BASED_ABSOLUTE = 0,
|
||||
IMAGE_REL_BASED_HIGH = 1,
|
||||
IMAGE_REL_BASED_LOW = 2,
|
||||
IMAGE_REL_BASED_HIGHLOW = 3,
|
||||
IMAGE_REL_BASED_HIGHADJ = 4,
|
||||
IMAGE_REL_BASED_MIPS_JMPADDR = 5,
|
||||
IMAGE_REL_BASED_ARM_MOV32A = 5,
|
||||
IMAGE_REL_BASED_ARM_MOV32T = 7,
|
||||
IMAGE_REL_BASED_MIPS_JMPADDR16 = 9,
|
||||
IMAGE_REL_BASED_DIR64 = 10
|
||||
};
|
||||
|
||||
enum ImportType { IMPORT_CODE = 0, IMPORT_DATA = 1, IMPORT_CONST = 2 };
|
||||
|
||||
enum ImportNameType {
|
||||
/// Import is by ordinal. This indicates that the value in the Ordinal/Hint
|
||||
/// field of the import header is the import's ordinal. If this constant is
|
||||
/// not specified, then the Ordinal/Hint field should always be interpreted
|
||||
/// as the import's hint.
|
||||
IMPORT_ORDINAL = 0,
|
||||
/// The import name is identical to the public symbol name
|
||||
IMPORT_NAME = 1,
|
||||
/// The import name is the public symbol name, but skipping the leading ?,
|
||||
/// @, or optionally _.
|
||||
IMPORT_NAME_NOPREFIX = 2,
|
||||
/// The import name is the public symbol name, but skipping the leading ?,
|
||||
/// @, or optionally _, and truncating at the first @.
|
||||
IMPORT_NAME_UNDECORATE = 3
|
||||
};
|
||||
|
||||
struct ImportHeader {
|
||||
uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0).
|
||||
uint16_t Sig2; ///< Must be 0xFFFF.
|
||||
uint16_t Version;
|
||||
uint16_t Machine;
|
||||
uint32_t TimeDateStamp;
|
||||
uint32_t SizeOfData;
|
||||
uint16_t OrdinalHint;
|
||||
uint16_t TypeInfo;
|
||||
|
||||
ImportType getType() const { return static_cast<ImportType>(TypeInfo & 0x3); }
|
||||
|
||||
ImportNameType getNameType() const {
|
||||
return static_cast<ImportNameType>((TypeInfo & 0x1C) >> 2);
|
||||
}
|
||||
};
|
||||
|
||||
enum CodeViewIdentifiers {
|
||||
DEBUG_SECTION_MAGIC = 0x4,
|
||||
};
|
||||
|
||||
inline bool isReservedSectionNumber(int32_t SectionNumber) {
|
||||
return SectionNumber <= 0;
|
||||
}
|
||||
|
||||
} // End namespace COFF.
|
||||
} // End namespace llvm.
|
||||
|
||||
#endif
|
@ -1,4 +1,4 @@
|
||||
//===-- llvm/Support/Dwarf.h ---Dwarf Constants------------------*- C++ -*-===//
|
||||
//===-- llvm/BinaryFormat/Dwarf.h ---Dwarf Constants-------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -17,8 +17,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_DWARF_H
|
||||
#define LLVM_SUPPORT_DWARF_H
|
||||
#ifndef LLVM_BINARYFORMAT_DWARF_H
|
||||
#define LLVM_BINARYFORMAT_DWARF_H
|
||||
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
@ -37,7 +37,7 @@ namespace dwarf {
|
||||
// enumeration base type.
|
||||
|
||||
enum LLVMConstants : uint32_t {
|
||||
// LLVM mock tags (see also llvm/Support/Dwarf.def).
|
||||
// LLVM mock tags (see also llvm/BinaryFormat/Dwarf.def).
|
||||
DW_TAG_invalid = ~0U, // Tag for invalid results.
|
||||
DW_VIRTUALITY_invalid = ~0U, // Virtuality for invalid results.
|
||||
DW_MACINFO_invalid = ~0U, // Macinfo type for invalid results.
|
||||
@ -48,7 +48,7 @@ enum LLVMConstants : uint32_t {
|
||||
DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames.
|
||||
DW_ARANGES_VERSION = 2, // Section version number for .debug_aranges.
|
||||
// Identifiers we use to distinguish vendor extensions.
|
||||
DWARF_VENDOR_DWARF = 0, // Defined in v2 or later of the DWARF standard.
|
||||
DWARF_VENDOR_DWARF = 0, // Defined in v2 or later of the DWARF standard.
|
||||
DWARF_VENDOR_APPLE = 1,
|
||||
DWARF_VENDOR_BORLAND = 2,
|
||||
DWARF_VENDOR_GNU = 3,
|
||||
@ -64,7 +64,7 @@ const uint64_t DW64_CIE_ID = UINT64_MAX;
|
||||
|
||||
enum Tag : uint16_t {
|
||||
#define HANDLE_DW_TAG(ID, NAME, VERSION, VENDOR) DW_TAG_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_TAG_lo_user = 0x4080,
|
||||
DW_TAG_hi_user = 0xffff,
|
||||
DW_TAG_user_base = 0x1000 // Recommended base for user tags.
|
||||
@ -101,20 +101,20 @@ inline bool isType(Tag T) {
|
||||
/// Attributes.
|
||||
enum Attribute : uint16_t {
|
||||
#define HANDLE_DW_AT(ID, NAME, VERSION, VENDOR) DW_AT_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_AT_lo_user = 0x2000,
|
||||
DW_AT_hi_user = 0x3fff,
|
||||
};
|
||||
|
||||
enum Form : uint16_t {
|
||||
#define HANDLE_DW_FORM(ID, NAME, VERSION, VENDOR) DW_FORM_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
DW_FORM_lo_user = 0x1f00, ///< Not specified by DWARF.
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_FORM_lo_user = 0x1f00, ///< Not specified by DWARF.
|
||||
};
|
||||
|
||||
enum LocationAtom {
|
||||
#define HANDLE_DW_OP(ID, NAME, VERSION, VENDOR) DW_OP_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_OP_lo_user = 0xe0,
|
||||
DW_OP_hi_user = 0xff,
|
||||
DW_OP_LLVM_fragment = 0x1000 ///< Only used in LLVM metadata.
|
||||
@ -122,7 +122,7 @@ enum LocationAtom {
|
||||
|
||||
enum TypeKind {
|
||||
#define HANDLE_DW_ATE(ID, NAME, VERSION, VENDOR) DW_ATE_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_ATE_lo_user = 0x80,
|
||||
DW_ATE_hi_user = 0xff
|
||||
};
|
||||
@ -161,19 +161,19 @@ enum VisibilityAttribute {
|
||||
|
||||
enum VirtualityAttribute {
|
||||
#define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_VIRTUALITY_max = 0x02
|
||||
};
|
||||
|
||||
enum DefaultedMemberAttribute {
|
||||
#define HANDLE_DW_DEFAULTED(ID, NAME) DW_DEFAULTED_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_DEFAULTED_max = 0x02
|
||||
};
|
||||
|
||||
enum SourceLanguage {
|
||||
#define HANDLE_DW_LANG(ID, NAME, VERSION, VENDOR) DW_LANG_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_LANG_lo_user = 0x8000,
|
||||
DW_LANG_hi_user = 0xffff
|
||||
};
|
||||
@ -187,9 +187,9 @@ enum CaseSensitivity {
|
||||
};
|
||||
|
||||
enum CallingConvention {
|
||||
// Calling convention codes
|
||||
// Calling convention codes
|
||||
#define HANDLE_DW_CC(ID, NAME) DW_CC_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_CC_lo_user = 0x40,
|
||||
DW_CC_hi_user = 0xff
|
||||
};
|
||||
@ -217,20 +217,20 @@ enum DiscriminantList {
|
||||
/// Line Number Standard Opcode Encodings.
|
||||
enum LineNumberOps : uint8_t {
|
||||
#define HANDLE_DW_LNS(ID, NAME) DW_LNS_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
};
|
||||
|
||||
/// Line Number Extended Opcode Encodings.
|
||||
enum LineNumberExtendedOps {
|
||||
#define HANDLE_DW_LNE(ID, NAME) DW_LNE_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_LNE_lo_user = 0x80,
|
||||
DW_LNE_hi_user = 0xff
|
||||
};
|
||||
|
||||
enum LineNumberEntryFormat {
|
||||
#define HANDLE_DW_LNCT(ID, NAME) DW_LNCT_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_LNCT_lo_user = 0x2000,
|
||||
DW_LNCT_hi_user = 0x3fff,
|
||||
};
|
||||
@ -247,7 +247,7 @@ enum MacinfoRecordType {
|
||||
/// DWARF v5 macro information entry type encodings.
|
||||
enum MacroEntryType {
|
||||
#define HANDLE_DW_MACRO(ID, NAME) DW_MACRO_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_MACRO_lo_user = 0xe0,
|
||||
DW_MACRO_hi_user = 0xff
|
||||
};
|
||||
@ -255,14 +255,13 @@ enum MacroEntryType {
|
||||
/// DWARF v5 range list entry encoding values.
|
||||
enum RangeListEntries {
|
||||
#define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
};
|
||||
|
||||
|
||||
/// Call frame instruction encodings.
|
||||
enum CallFrameInfo {
|
||||
#define HANDLE_DW_CFA(ID, NAME) DW_CFA_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_CFA_extended = 0x00,
|
||||
|
||||
DW_CFA_lo_user = 0x1c,
|
||||
@ -310,13 +309,13 @@ enum LocationListEntry : unsigned char {
|
||||
/// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
|
||||
enum ApplePropertyAttributes {
|
||||
#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
};
|
||||
|
||||
/// Constants for unit types in DWARF v5.
|
||||
enum UnitType : unsigned char {
|
||||
#define HANDLE_DW_UT(ID, NAME) DW_UT_##NAME = ID,
|
||||
#include "llvm/Support/Dwarf.def"
|
||||
#include "llvm/BinaryFormat/Dwarf.def"
|
||||
DW_UT_lo_user = 0x80,
|
||||
DW_UT_hi_user = 0xff
|
||||
};
|
||||
@ -355,10 +354,7 @@ enum GDBIndexEntryKind {
|
||||
GIEK_UNUSED7
|
||||
};
|
||||
|
||||
enum GDBIndexEntryLinkage {
|
||||
GIEL_EXTERNAL,
|
||||
GIEL_STATIC
|
||||
};
|
||||
enum GDBIndexEntryLinkage { GIEL_EXTERNAL, GIEL_STATIC };
|
||||
|
||||
/// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
|
||||
///
|
||||
@ -470,8 +466,8 @@ struct PubIndexEntryDescriptor {
|
||||
/* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
|
||||
: Kind(Kind), Linkage(GIEL_EXTERNAL) {}
|
||||
explicit PubIndexEntryDescriptor(uint8_t Value)
|
||||
: Kind(static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >>
|
||||
KIND_OFFSET)),
|
||||
: Kind(
|
||||
static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >> KIND_OFFSET)),
|
||||
Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
|
||||
LINKAGE_OFFSET)) {}
|
||||
uint8_t toBits() const {
|
@ -1,4 +1,4 @@
|
||||
//===-- llvm/Support/ELF.h - ELF constants and data structures --*- C++ -*-===//
|
||||
//===-- llvm/BinaryFormat/ELF.h - ELF constants and structures --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -17,8 +17,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_ELF_H
|
||||
#define LLVM_SUPPORT_ELF_H
|
||||
#ifndef LLVM_BINARYFORMAT_ELF_H
|
||||
#define LLVM_BINARYFORMAT_ELF_H
|
||||
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
@ -808,12 +808,7 @@ enum : unsigned {
|
||||
SHF_MIPS_STRING = 0x80000000,
|
||||
|
||||
// Make code section unreadable when in execute-only mode
|
||||
SHF_ARM_PURECODE = 0x20000000,
|
||||
|
||||
SHF_AMDGPU_HSA_GLOBAL = 0x00100000,
|
||||
SHF_AMDGPU_HSA_READONLY = 0x00200000,
|
||||
SHF_AMDGPU_HSA_CODE = 0x00400000,
|
||||
SHF_AMDGPU_HSA_AGENT = 0x00800000
|
||||
SHF_ARM_PURECODE = 0x20000000
|
||||
};
|
||||
|
||||
// Section Group Flags
|
||||
@ -897,9 +892,7 @@ enum {
|
||||
STT_HIPROC = 15, // Highest processor-specific symbol type
|
||||
|
||||
// AMDGPU symbol types
|
||||
STT_AMDGPU_HSA_KERNEL = 10,
|
||||
STT_AMDGPU_HSA_INDIRECT_FUNCTION = 11,
|
||||
STT_AMDGPU_HSA_METADATA = 12
|
||||
STT_AMDGPU_HSA_KERNEL = 10
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -1050,12 +1043,6 @@ enum {
|
||||
PT_MIPS_OPTIONS = 0x70000002, // Options segment.
|
||||
PT_MIPS_ABIFLAGS = 0x70000003, // Abiflags segment.
|
||||
|
||||
// AMDGPU program header types.
|
||||
PT_AMDGPU_HSA_LOAD_GLOBAL_PROGRAM = 0x60000000,
|
||||
PT_AMDGPU_HSA_LOAD_GLOBAL_AGENT = 0x60000001,
|
||||
PT_AMDGPU_HSA_LOAD_READONLY_AGENT = 0x60000002,
|
||||
PT_AMDGPU_HSA_LOAD_CODE_AGENT = 0x60000003,
|
||||
|
||||
// WebAssembly program header types.
|
||||
PT_WEBASSEMBLY_FUNCTIONS = PT_LOPROC + 0, // Function definitions.
|
||||
};
|
1984
include/llvm/BinaryFormat/MachO.h
Normal file
1984
include/llvm/BinaryFormat/MachO.h
Normal file
File diff suppressed because it is too large
Load Diff
73
include/llvm/BinaryFormat/Magic.h
Normal file
73
include/llvm/BinaryFormat/Magic.h
Normal file
@ -0,0 +1,73 @@
|
||||
//===- llvm/BinaryFormat/Magic.h - File magic identification ----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_BINARYFORMAT_MAGIC_H
|
||||
#define LLVM_BINARYFORMAT_MAGIC_H
|
||||
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/Twine.h"
|
||||
|
||||
#include <system_error>
|
||||
|
||||
namespace llvm {
|
||||
/// file_magic - An "enum class" enumeration of file types based on magic (the
|
||||
/// first N bytes of the file).
|
||||
struct file_magic {
|
||||
enum Impl {
|
||||
unknown = 0, ///< Unrecognized file
|
||||
bitcode, ///< Bitcode file
|
||||
archive, ///< ar style archive file
|
||||
elf, ///< ELF Unknown type
|
||||
elf_relocatable, ///< ELF Relocatable object file
|
||||
elf_executable, ///< ELF Executable image
|
||||
elf_shared_object, ///< ELF dynamically linked shared lib
|
||||
elf_core, ///< ELF core image
|
||||
macho_object, ///< Mach-O Object file
|
||||
macho_executable, ///< Mach-O Executable
|
||||
macho_fixed_virtual_memory_shared_lib, ///< Mach-O Shared Lib, FVM
|
||||
macho_core, ///< Mach-O Core File
|
||||
macho_preload_executable, ///< Mach-O Preloaded Executable
|
||||
macho_dynamically_linked_shared_lib, ///< Mach-O dynlinked shared lib
|
||||
macho_dynamic_linker, ///< The Mach-O dynamic linker
|
||||
macho_bundle, ///< Mach-O Bundle file
|
||||
macho_dynamically_linked_shared_lib_stub, ///< Mach-O Shared lib stub
|
||||
macho_dsym_companion, ///< Mach-O dSYM companion file
|
||||
macho_kext_bundle, ///< Mach-O kext bundle file
|
||||
macho_universal_binary, ///< Mach-O universal binary
|
||||
coff_cl_gl_object, ///< Microsoft cl.exe's intermediate code file
|
||||
coff_object, ///< COFF object file
|
||||
coff_import_library, ///< COFF import library
|
||||
pecoff_executable, ///< PECOFF executable file
|
||||
windows_resource, ///< Windows compiled resource file (.res)
|
||||
wasm_object ///< WebAssembly Object file
|
||||
};
|
||||
|
||||
bool is_object() const { return V != unknown; }
|
||||
|
||||
file_magic() = default;
|
||||
file_magic(Impl V) : V(V) {}
|
||||
operator Impl() const { return V; }
|
||||
|
||||
private:
|
||||
Impl V = unknown;
|
||||
};
|
||||
|
||||
/// @brief Identify the type of a binary file based on how magical it is.
|
||||
file_magic identify_magic(StringRef magic);
|
||||
|
||||
/// @brief Get and identify \a path's type based on its content.
|
||||
///
|
||||
/// @param path Input path.
|
||||
/// @param result Set to the type of file, or file_magic::unknown.
|
||||
/// @returns errc::success if result has been successfully set, otherwise a
|
||||
/// platform-specific error_code.
|
||||
std::error_code identify_magic(const Twine &path, file_magic &result);
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
@ -12,8 +12,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SUPPORT_WASM_H
|
||||
#define LLVM_SUPPORT_WASM_H
|
||||
#ifndef LLVM_BINARYFORMAT_WASM_H
|
||||
#define LLVM_BINARYFORMAT_WASM_H
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
|
||||
@ -106,10 +106,10 @@ struct WasmElemSegment {
|
||||
};
|
||||
|
||||
struct WasmRelocation {
|
||||
uint32_t Type; // The type of the relocation.
|
||||
int32_t Index; // Index into function to global index space.
|
||||
uint64_t Offset; // Offset from the start of the section.
|
||||
int64_t Addend; // A value to add to the symbol.
|
||||
uint32_t Type; // The type of the relocation.
|
||||
int32_t Index; // Index into function to global index space.
|
||||
uint64_t Offset; // Offset from the start of the section.
|
||||
int64_t Addend; // A value to add to the symbol.
|
||||
};
|
||||
|
||||
enum : unsigned {
|
||||
@ -129,36 +129,36 @@ enum : unsigned {
|
||||
|
||||
// Type immediate encodings used in various contexts.
|
||||
enum {
|
||||
WASM_TYPE_I32 = -0x01,
|
||||
WASM_TYPE_I64 = -0x02,
|
||||
WASM_TYPE_F32 = -0x03,
|
||||
WASM_TYPE_F64 = -0x04,
|
||||
WASM_TYPE_ANYFUNC = -0x10,
|
||||
WASM_TYPE_FUNC = -0x20,
|
||||
WASM_TYPE_NORESULT = -0x40, // for blocks with no result values
|
||||
WASM_TYPE_I32 = -0x01,
|
||||
WASM_TYPE_I64 = -0x02,
|
||||
WASM_TYPE_F32 = -0x03,
|
||||
WASM_TYPE_F64 = -0x04,
|
||||
WASM_TYPE_ANYFUNC = -0x10,
|
||||
WASM_TYPE_FUNC = -0x20,
|
||||
WASM_TYPE_NORESULT = -0x40, // for blocks with no result values
|
||||
};
|
||||
|
||||
// Kinds of externals (for imports and exports).
|
||||
enum : unsigned {
|
||||
WASM_EXTERNAL_FUNCTION = 0x0,
|
||||
WASM_EXTERNAL_TABLE = 0x1,
|
||||
WASM_EXTERNAL_MEMORY = 0x2,
|
||||
WASM_EXTERNAL_GLOBAL = 0x3,
|
||||
WASM_EXTERNAL_TABLE = 0x1,
|
||||
WASM_EXTERNAL_MEMORY = 0x2,
|
||||
WASM_EXTERNAL_GLOBAL = 0x3,
|
||||
};
|
||||
|
||||
// Opcodes used in initializer expressions.
|
||||
enum : unsigned {
|
||||
WASM_OPCODE_END = 0x0b,
|
||||
WASM_OPCODE_END = 0x0b,
|
||||
WASM_OPCODE_GET_GLOBAL = 0x23,
|
||||
WASM_OPCODE_I32_CONST = 0x41,
|
||||
WASM_OPCODE_I64_CONST = 0x42,
|
||||
WASM_OPCODE_F32_CONST = 0x43,
|
||||
WASM_OPCODE_F64_CONST = 0x44,
|
||||
WASM_OPCODE_I32_CONST = 0x41,
|
||||
WASM_OPCODE_I64_CONST = 0x42,
|
||||
WASM_OPCODE_F32_CONST = 0x43,
|
||||
WASM_OPCODE_F64_CONST = 0x44,
|
||||
};
|
||||
|
||||
enum : unsigned {
|
||||
WASM_NAMES_FUNCTION = 0x1,
|
||||
WASM_NAMES_LOCAL = 0x2,
|
||||
WASM_NAMES_FUNCTION = 0x1,
|
||||
WASM_NAMES_LOCAL = 0x2,
|
||||
};
|
||||
|
||||
enum : unsigned {
|
@ -40,6 +40,8 @@ namespace llvm {
|
||||
return std::move(*Val);
|
||||
}
|
||||
|
||||
struct BitcodeFileContents;
|
||||
|
||||
/// Represents a module in a bitcode file.
|
||||
class BitcodeModule {
|
||||
// This covers the identification (if present) and module blocks.
|
||||
@ -61,8 +63,8 @@ namespace llvm {
|
||||
IdentificationBit(IdentificationBit), ModuleBit(ModuleBit) {}
|
||||
|
||||
// Calls the ctor.
|
||||
friend Expected<std::vector<BitcodeModule>>
|
||||
getBitcodeModuleList(MemoryBufferRef Buffer);
|
||||
friend Expected<BitcodeFileContents>
|
||||
getBitcodeFileContents(MemoryBufferRef Buffer);
|
||||
|
||||
Expected<std::unique_ptr<Module>> getModuleImpl(LLVMContext &Context,
|
||||
bool MaterializeAll,
|
||||
@ -99,6 +101,13 @@ namespace llvm {
|
||||
Error readSummary(ModuleSummaryIndex &CombinedIndex, unsigned ModuleId);
|
||||
};
|
||||
|
||||
struct BitcodeFileContents {
|
||||
std::vector<BitcodeModule> Mods;
|
||||
};
|
||||
|
||||
/// Returns the contents of a bitcode file.
|
||||
Expected<BitcodeFileContents> getBitcodeFileContents(MemoryBufferRef Buffer);
|
||||
|
||||
/// Returns a list of modules in the specified bitcode buffer.
|
||||
Expected<std::vector<BitcodeModule>>
|
||||
getBitcodeModuleList(MemoryBufferRef Buffer);
|
||||
|
@ -55,6 +55,8 @@ enum BlockIDs {
|
||||
METADATA_KIND_BLOCK_ID,
|
||||
|
||||
STRTAB_BLOCK_ID,
|
||||
|
||||
FULL_LTO_GLOBALVAL_SUMMARY_BLOCK_ID,
|
||||
};
|
||||
|
||||
/// Identification block contains a string that describes the producer details,
|
||||
|
@ -17,11 +17,11 @@
|
||||
#define LLVM_CODEGEN_BASICTTIIMPL_H
|
||||
|
||||
#include "llvm/Analysis/LoopInfo.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
#include "llvm/Analysis/TargetTransformInfoImpl.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Target/TargetLowering.h"
|
||||
#include "llvm/Target/TargetSubtargetInfo.h"
|
||||
#include "llvm/Analysis/TargetLibraryInfo.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -117,6 +117,10 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
|
||||
return getTLI()->isLegalAddressingMode(DL, AM, Ty, AddrSpace);
|
||||
}
|
||||
|
||||
bool isLSRCostLess(TTI::LSRCost C1, TTI::LSRCost C2) {
|
||||
return TargetTransformInfoImplBase::isLSRCostLess(C1, C2);
|
||||
}
|
||||
|
||||
int getScalingFactorCost(Type *Ty, GlobalValue *BaseGV, int64_t BaseOffset,
|
||||
bool HasBaseReg, int64_t Scale, unsigned AddrSpace) {
|
||||
TargetLoweringBase::AddrMode AM;
|
||||
@ -1080,46 +1084,46 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// Try to calculate arithmetic and shuffle op costs for reduction operations.
|
||||
/// We're assuming that reduction operation are performing the following way:
|
||||
/// 1. Non-pairwise reduction
|
||||
/// %val1 = shufflevector<n x t> %val, <n x t> %undef,
|
||||
/// <n x i32> <i32 n/2, i32 n/2 + 1, ..., i32 n, i32 undef, ..., i32 undef>
|
||||
/// \----------------v-------------/ \----------v------------/
|
||||
/// n/2 elements n/2 elements
|
||||
/// %red1 = op <n x t> %val, <n x t> val1
|
||||
/// After this operation we have a vector %red1 where only the first n/2
|
||||
/// elements are meaningful, the second n/2 elements are undefined and can be
|
||||
/// dropped. All other operations are actually working with the vector of
|
||||
/// length n/2, not n, though the real vector length is still n.
|
||||
/// %val2 = shufflevector<n x t> %red1, <n x t> %undef,
|
||||
/// <n x i32> <i32 n/4, i32 n/4 + 1, ..., i32 n/2, i32 undef, ..., i32 undef>
|
||||
/// \----------------v-------------/ \----------v------------/
|
||||
/// n/4 elements 3*n/4 elements
|
||||
/// %red2 = op <n x t> %red1, <n x t> val2 - working with the vector of
|
||||
/// length n/2, the resulting vector has length n/4 etc.
|
||||
/// 2. Pairwise reduction:
|
||||
/// Everything is the same except for an additional shuffle operation which
|
||||
/// is used to produce operands for pairwise kind of reductions.
|
||||
/// %val1 = shufflevector<n x t> %val, <n x t> %undef,
|
||||
/// <n x i32> <i32 0, i32 2, ..., i32 n-2, i32 undef, ..., i32 undef>
|
||||
/// \-------------v----------/ \----------v------------/
|
||||
/// n/2 elements n/2 elements
|
||||
/// %val2 = shufflevector<n x t> %val, <n x t> %undef,
|
||||
/// <n x i32> <i32 1, i32 3, ..., i32 n-1, i32 undef, ..., i32 undef>
|
||||
/// \-------------v----------/ \----------v------------/
|
||||
/// n/2 elements n/2 elements
|
||||
/// %red1 = op <n x t> %val1, <n x t> val2
|
||||
/// Again, the operation is performed on <n x t> vector, but the resulting
|
||||
/// vector %red1 is <n/2 x t> vector.
|
||||
///
|
||||
/// The cost model should take into account that the actual length of the
|
||||
/// vector is reduced on each iteration.
|
||||
unsigned getReductionCost(unsigned Opcode, Type *Ty, bool IsPairwise) {
|
||||
assert(Ty->isVectorTy() && "Expect a vector type");
|
||||
Type *ScalarTy = Ty->getVectorElementType();
|
||||
unsigned NumVecElts = Ty->getVectorNumElements();
|
||||
unsigned NumReduxLevels = Log2_32(NumVecElts);
|
||||
// Try to calculate arithmetic and shuffle op costs for reduction operations.
|
||||
// We're assuming that reduction operation are performing the following way:
|
||||
// 1. Non-pairwise reduction
|
||||
// %val1 = shufflevector<n x t> %val, <n x t> %undef,
|
||||
// <n x i32> <i32 n/2, i32 n/2 + 1, ..., i32 n, i32 undef, ..., i32 undef>
|
||||
// \----------------v-------------/ \----------v------------/
|
||||
// n/2 elements n/2 elements
|
||||
// %red1 = op <n x t> %val, <n x t> val1
|
||||
// After this operation we have a vector %red1 with only maningfull the
|
||||
// first n/2 elements, the second n/2 elements are undefined and can be
|
||||
// dropped. All other operations are actually working with the vector of
|
||||
// length n/2, not n. though the real vector length is still n.
|
||||
// %val2 = shufflevector<n x t> %red1, <n x t> %undef,
|
||||
// <n x i32> <i32 n/4, i32 n/4 + 1, ..., i32 n/2, i32 undef, ..., i32 undef>
|
||||
// \----------------v-------------/ \----------v------------/
|
||||
// n/4 elements 3*n/4 elements
|
||||
// %red2 = op <n x t> %red1, <n x t> val2 - working with the vector of
|
||||
// length n/2, the resulting vector has length n/4 etc.
|
||||
// 2. Pairwise reduction:
|
||||
// Everything is the same except for an additional shuffle operation which
|
||||
// is used to produce operands for pairwise kind of reductions.
|
||||
// %val1 = shufflevector<n x t> %val, <n x t> %undef,
|
||||
// <n x i32> <i32 0, i32 2, ..., i32 n-2, i32 undef, ..., i32 undef>
|
||||
// \-------------v----------/ \----------v------------/
|
||||
// n/2 elements n/2 elements
|
||||
// %val2 = shufflevector<n x t> %val, <n x t> %undef,
|
||||
// <n x i32> <i32 1, i32 3, ..., i32 n-1, i32 undef, ..., i32 undef>
|
||||
// \-------------v----------/ \----------v------------/
|
||||
// n/2 elements n/2 elements
|
||||
// %red1 = op <n x t> %val1, <n x t> val2
|
||||
// Again, the operation is performed on <n x t> vector, but the resulting
|
||||
// vector %red1 is <n/2 x t> vector.
|
||||
//
|
||||
// The cost model should take into account that the actual length of the
|
||||
// vector is reduced on each iteration.
|
||||
unsigned ArithCost = 0;
|
||||
unsigned ShuffleCost = 0;
|
||||
auto *ConcreteTTI = static_cast<T *>(this);
|
||||
|
@ -1,4 +1,4 @@
|
||||
//=- llvm/CodeGen/DFAPacketizer.h - DFA Packetizer for VLIW ---*- C++ -*-=====//
|
||||
//===- llvm/CodeGen/DFAPacketizer.h - DFA Packetizer for VLIW ---*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -29,17 +29,22 @@
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/CodeGen/ScheduleDAGMutation.h"
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MCInstrDesc;
|
||||
class DefaultVLIWScheduler;
|
||||
class InstrItineraryData;
|
||||
class MachineFunction;
|
||||
class MachineInstr;
|
||||
class MachineLoopInfo;
|
||||
class MachineDominatorTree;
|
||||
class InstrItineraryData;
|
||||
class DefaultVLIWScheduler;
|
||||
class MCInstrDesc;
|
||||
class SUnit;
|
||||
class TargetInstrInfo;
|
||||
|
||||
// --------------------------------------------------------------------
|
||||
// Definitions shared between DFAPacketizer.cpp and DFAPacketizerEmitter.cpp
|
||||
@ -64,17 +69,18 @@ class SUnit;
|
||||
#define DFA_MAX_RESTERMS 4 // The max # of AND'ed resource terms.
|
||||
#define DFA_MAX_RESOURCES 16 // The max # of resource bits in one term.
|
||||
|
||||
typedef uint64_t DFAInput;
|
||||
typedef int64_t DFAStateInput;
|
||||
using DFAInput = uint64_t;
|
||||
using DFAStateInput = int64_t;
|
||||
|
||||
#define DFA_TBLTYPE "int64_t" // For generating DFAStateInputTable.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
class DFAPacketizer {
|
||||
private:
|
||||
typedef std::pair<unsigned, DFAInput> UnsignPair;
|
||||
using UnsignPair = std::pair<unsigned, DFAInput>;
|
||||
|
||||
const InstrItineraryData *InstrItins;
|
||||
int CurrentState;
|
||||
int CurrentState = 0;
|
||||
const DFAStateInput (*DFAStateInputTable)[2];
|
||||
const unsigned *DFAStateEntryTable;
|
||||
|
||||
@ -101,24 +107,23 @@ class DFAPacketizer {
|
||||
|
||||
// Check if the resources occupied by a MCInstrDesc are available in
|
||||
// the current state.
|
||||
bool canReserveResources(const llvm::MCInstrDesc *MID);
|
||||
bool canReserveResources(const MCInstrDesc *MID);
|
||||
|
||||
// Reserve the resources occupied by a MCInstrDesc and change the current
|
||||
// state to reflect that change.
|
||||
void reserveResources(const llvm::MCInstrDesc *MID);
|
||||
void reserveResources(const MCInstrDesc *MID);
|
||||
|
||||
// Check if the resources occupied by a machine instruction are available
|
||||
// in the current state.
|
||||
bool canReserveResources(llvm::MachineInstr &MI);
|
||||
bool canReserveResources(MachineInstr &MI);
|
||||
|
||||
// Reserve the resources occupied by a machine instruction and change the
|
||||
// current state to reflect that change.
|
||||
void reserveResources(llvm::MachineInstr &MI);
|
||||
void reserveResources(MachineInstr &MI);
|
||||
|
||||
const InstrItineraryData *getInstrItins() const { return InstrItins; }
|
||||
};
|
||||
|
||||
|
||||
// VLIWPacketizerList implements a simple VLIW packetizer using DFA. The
|
||||
// packetizer works on machine basic blocks. For each instruction I in BB,
|
||||
// the packetizer consults the DFA to see if machine resources are available
|
||||
@ -205,6 +210,6 @@ class VLIWPacketizerList {
|
||||
void addMutation(std::unique_ptr<ScheduleDAGMutation> Mutation);
|
||||
};
|
||||
|
||||
} // namespace llvm
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CODEGEN_DFAPACKETIZER_H
|
||||
|
@ -21,10 +21,10 @@
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/iterator.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/BinaryFormat/Dwarf.h"
|
||||
#include "llvm/CodeGen/DwarfStringPoolEntry.h"
|
||||
#include "llvm/Support/AlignOf.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include "llvm/Support/Dwarf.h"
|
||||
#include <cassert>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===- llvm/CodeGen/ExecutionDepsFix.h - Execution Dependency Fix -*- C++ -*-=//
|
||||
//==- llvm/CodeGen/ExecutionDepsFix.h - Execution Dependency Fix -*- C++ -*-==//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -20,19 +20,30 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
|
||||
#ifndef LLVM_CODEGEN_EXECUTIONDEPSFIX_H
|
||||
#define LLVM_CODEGEN_EXECUTIONDEPSFIX_H
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/CodeGen/LivePhysRegs.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/RegisterClassInfo.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <cassert>
|
||||
#include <limits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MachineBasicBlock;
|
||||
class MachineInstr;
|
||||
class TargetInstrInfo;
|
||||
|
||||
/// A DomainValue is a bit like LiveIntervals' ValNo, but it also keeps track
|
||||
/// of execution domains.
|
||||
///
|
||||
@ -50,7 +61,7 @@ namespace llvm {
|
||||
/// domains.
|
||||
struct DomainValue {
|
||||
// Basic reference counting.
|
||||
unsigned Refs;
|
||||
unsigned Refs = 0;
|
||||
|
||||
// Bitmask of available domains. For an open DomainValue, it is the still
|
||||
// possible domains for collapsing. For a collapsed DomainValue it is the
|
||||
@ -65,6 +76,8 @@ struct DomainValue {
|
||||
// Twiddleable instructions using or defining these registers.
|
||||
SmallVector<MachineInstr*, 8> Instrs;
|
||||
|
||||
DomainValue() { clear(); }
|
||||
|
||||
// A collapsed DomainValue has no instructions to twiddle - it simply keeps
|
||||
// track of the domains where the registers are already available.
|
||||
bool isCollapsed() const { return Instrs.empty(); }
|
||||
@ -97,8 +110,6 @@ struct DomainValue {
|
||||
return countTrailingZeros(AvailableDomains);
|
||||
}
|
||||
|
||||
DomainValue() : Refs(0) { clear(); }
|
||||
|
||||
// Clear this DomainValue and point to next which has all its data.
|
||||
void clear() {
|
||||
AvailableDomains = 0;
|
||||
@ -136,29 +147,27 @@ class ExecutionDepsFix : public MachineFunctionPass {
|
||||
// Keeps clearance and domain information for all registers. Note that this
|
||||
// is different from the usual definition notion of liveness. The CPU
|
||||
// doesn't care whether or not we consider a register killed.
|
||||
LiveReg *OutRegs;
|
||||
LiveReg *OutRegs = nullptr;
|
||||
|
||||
// Whether we have gotten to this block in primary processing yet.
|
||||
bool PrimaryCompleted;
|
||||
bool PrimaryCompleted = false;
|
||||
|
||||
// The number of predecessors for which primary processing has completed
|
||||
unsigned IncomingProcessed;
|
||||
unsigned IncomingProcessed = 0;
|
||||
|
||||
// The value of `IncomingProcessed` at the start of primary processing
|
||||
unsigned PrimaryIncoming;
|
||||
unsigned PrimaryIncoming = 0;
|
||||
|
||||
// The number of predecessors for which all processing steps are done.
|
||||
unsigned IncomingCompleted;
|
||||
unsigned IncomingCompleted = 0;
|
||||
|
||||
MBBInfo()
|
||||
: OutRegs(nullptr), PrimaryCompleted(false), IncomingProcessed(0),
|
||||
PrimaryIncoming(0), IncomingCompleted(0) {}
|
||||
MBBInfo() = default;
|
||||
};
|
||||
typedef DenseMap<MachineBasicBlock *, MBBInfo> MBBInfoMap;
|
||||
using MBBInfoMap = DenseMap<MachineBasicBlock *, MBBInfo>;
|
||||
MBBInfoMap MBBInfos;
|
||||
|
||||
/// List of undefined register reads in this block in forward order.
|
||||
std::vector<std::pair<MachineInstr*, unsigned> > UndefReads;
|
||||
std::vector<std::pair<MachineInstr *, unsigned>> UndefReads;
|
||||
|
||||
/// Storage for register unit liveness.
|
||||
LivePhysRegs LiveRegSet;
|
||||
@ -166,6 +175,7 @@ class ExecutionDepsFix : public MachineFunctionPass {
|
||||
/// Current instruction number.
|
||||
/// The first instruction in each basic block is 0.
|
||||
int CurInstr;
|
||||
|
||||
public:
|
||||
ExecutionDepsFix(char &PassID, const TargetRegisterClass &RC)
|
||||
: MachineFunctionPass(PassID), RC(&RC), NumRegs(RC.getNumRegs()) {}
|
||||
@ -217,4 +227,4 @@ class ExecutionDepsFix : public MachineFunctionPass {
|
||||
|
||||
} // end namepsace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CODEGEN_EXECUTIONDEPSFIX_H
|
||||
|
@ -17,11 +17,12 @@
|
||||
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/CodeGen/MachineValueType.h"
|
||||
#include "llvm/IR/Attributes.h"
|
||||
#include "llvm/IR/CallingConv.h"
|
||||
#include "llvm/IR/CallSite.h"
|
||||
#include "llvm/IR/CallingConv.h"
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
#include "llvm/IR/DerivedTypes.h"
|
||||
#include "llvm/IR/InstrTypes.h"
|
||||
@ -30,19 +31,43 @@
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class AllocaInst;
|
||||
class BasicBlock;
|
||||
class CallInst;
|
||||
class Constant;
|
||||
class ConstantFP;
|
||||
class DataLayout;
|
||||
class FunctionLoweringInfo;
|
||||
class LoadInst;
|
||||
class MachineConstantPool;
|
||||
class MachineFrameInfo;
|
||||
class MachineFunction;
|
||||
class MachineInstr;
|
||||
class MachineMemOperand;
|
||||
class MachineOperand;
|
||||
class MachineRegisterInfo;
|
||||
class MCContext;
|
||||
class MCInstrDesc;
|
||||
class MCSymbol;
|
||||
class TargetInstrInfo;
|
||||
class TargetLibraryInfo;
|
||||
class TargetMachine;
|
||||
class TargetRegisterClass;
|
||||
class TargetRegisterInfo;
|
||||
class Type;
|
||||
class User;
|
||||
class Value;
|
||||
|
||||
/// \brief This is a fast-path instruction selection class that generates poor
|
||||
/// code and doesn't support illegal types or non-trivial lowering, but runs
|
||||
/// quickly.
|
||||
class FastISel {
|
||||
public:
|
||||
typedef TargetLoweringBase::ArgListEntry ArgListEntry;
|
||||
typedef TargetLoweringBase::ArgListTy ArgListTy;
|
||||
using ArgListEntry = TargetLoweringBase::ArgListEntry;
|
||||
using ArgListTy = TargetLoweringBase::ArgListTy;
|
||||
struct CallLoweringInfo {
|
||||
Type *RetTy = nullptr;
|
||||
bool RetSExt : 1;
|
||||
@ -202,6 +227,8 @@ class FastISel {
|
||||
MachineInstr *EmitStartPt;
|
||||
|
||||
public:
|
||||
virtual ~FastISel();
|
||||
|
||||
/// \brief Return the position of the last instruction emitted for
|
||||
/// materializing constants for use in the current block.
|
||||
MachineInstr *getLastLocalValue() { return LastLocalValue; }
|
||||
@ -293,8 +320,6 @@ class FastISel {
|
||||
/// \brief Reset InsertPt to the given old insert position.
|
||||
void leaveLocalValueArea(SavePoint Old);
|
||||
|
||||
virtual ~FastISel();
|
||||
|
||||
protected:
|
||||
explicit FastISel(FunctionLoweringInfo &FuncInfo,
|
||||
const TargetLibraryInfo *LibInfo,
|
||||
@ -334,7 +359,7 @@ class FastISel {
|
||||
|
||||
/// \brief This method is called by target-independent code to request that an
|
||||
/// instruction with the given type, opcode, and register and immediate
|
||||
// operands be emitted.
|
||||
/// operands be emitted.
|
||||
virtual unsigned fastEmit_ri(MVT VT, MVT RetVT, unsigned Opcode, unsigned Op0,
|
||||
bool Op0IsKill, uint64_t Imm);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- FunctionLoweringInfo.h - Lower functions from LLVM IR to CodeGen --===//
|
||||
//===- FunctionLoweringInfo.h - Lower functions from LLVM IR to CodeGen ---===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -23,29 +23,28 @@
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/CodeGen/ISDOpcodes.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/IR/InlineAsm.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/Type.h"
|
||||
#include "llvm/IR/Value.h"
|
||||
#include "llvm/Support/KnownBits.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include <cassert>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class AllocaInst;
|
||||
class Argument;
|
||||
class BasicBlock;
|
||||
class BranchProbabilityInfo;
|
||||
class Function;
|
||||
class GlobalVariable;
|
||||
class Instruction;
|
||||
class MachineInstr;
|
||||
class MachineBasicBlock;
|
||||
class MachineFunction;
|
||||
class MachineModuleInfo;
|
||||
class MachineInstr;
|
||||
class MachineRegisterInfo;
|
||||
class SelectionDAG;
|
||||
class MVT;
|
||||
class SelectionDAG;
|
||||
class TargetLowering;
|
||||
class Value;
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
/// FunctionLoweringInfo - This contains information that is global to a
|
||||
@ -74,25 +73,24 @@ class FunctionLoweringInfo {
|
||||
|
||||
/// A map from swifterror value in a basic block to the virtual register it is
|
||||
/// currently represented by.
|
||||
llvm::DenseMap<std::pair<const MachineBasicBlock *, const Value *>, unsigned>
|
||||
DenseMap<std::pair<const MachineBasicBlock *, const Value *>, unsigned>
|
||||
SwiftErrorVRegDefMap;
|
||||
|
||||
/// A list of upward exposed vreg uses that need to be satisfied by either a
|
||||
/// copy def or a phi node at the beginning of the basic block representing
|
||||
/// the predecessor(s) swifterror value.
|
||||
llvm::DenseMap<std::pair<const MachineBasicBlock *, const Value *>, unsigned>
|
||||
DenseMap<std::pair<const MachineBasicBlock *, const Value *>, unsigned>
|
||||
SwiftErrorVRegUpwardsUse;
|
||||
|
||||
/// The swifterror argument of the current function.
|
||||
const Value *SwiftErrorArg;
|
||||
|
||||
typedef SmallVector<const Value*, 1> SwiftErrorValues;
|
||||
using SwiftErrorValues = SmallVector<const Value*, 1>;
|
||||
/// A function can only have a single swifterror argument. And if it does
|
||||
/// have a swifterror argument, it must be the first entry in
|
||||
/// SwiftErrorVals.
|
||||
SwiftErrorValues SwiftErrorVals;
|
||||
|
||||
|
||||
/// Get or create the swifterror value virtual register in
|
||||
/// SwiftErrorVRegDefMap for this basic block.
|
||||
unsigned getOrCreateSwiftErrorVReg(const MachineBasicBlock *,
|
||||
@ -118,7 +116,7 @@ class FunctionLoweringInfo {
|
||||
/// slot), and we track that here.
|
||||
|
||||
struct StatepointSpillMap {
|
||||
typedef DenseMap<const Value *, Optional<int>> SlotMapTy;
|
||||
using SlotMapTy = DenseMap<const Value *, Optional<int>>;
|
||||
|
||||
/// Maps uniqued llvm IR values to the slots they were spilled in. If a
|
||||
/// value is mapped to None it means we visited the value but didn't spill
|
||||
@ -172,8 +170,9 @@ class FunctionLoweringInfo {
|
||||
struct LiveOutInfo {
|
||||
unsigned NumSignBits : 31;
|
||||
unsigned IsValid : 1;
|
||||
KnownBits Known;
|
||||
LiveOutInfo() : NumSignBits(0), IsValid(true), Known(1) {}
|
||||
KnownBits Known = 1;
|
||||
|
||||
LiveOutInfo() : NumSignBits(0), IsValid(true) {}
|
||||
};
|
||||
|
||||
/// Record the preferred extend type (ISD::SIGN_EXTEND or ISD::ZERO_EXTEND)
|
||||
@ -298,4 +297,4 @@ class FunctionLoweringInfo {
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif
|
||||
#endif // LLVM_CODEGEN_FUNCTIONLOWERINGINFO_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- GCMetadata.h - Garbage collector metadata ---------------*- C++ -*-===//
|
||||
//===- GCMetadata.h - Garbage collector metadata ----------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -36,15 +36,20 @@
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/CodeGen/GCStrategy.h"
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
namespace llvm {
|
||||
class AsmPrinter;
|
||||
|
||||
class Constant;
|
||||
class Function;
|
||||
class MCSymbol;
|
||||
|
||||
/// GCPoint - Metadata for a collector-safe point in machine code.
|
||||
@ -62,20 +67,20 @@ struct GCPoint {
|
||||
/// collector.
|
||||
struct GCRoot {
|
||||
int Num; ///< Usually a frame index.
|
||||
int StackOffset; ///< Offset from the stack pointer.
|
||||
int StackOffset = -1; ///< Offset from the stack pointer.
|
||||
const Constant *Metadata; ///< Metadata straight from the call
|
||||
///< to llvm.gcroot.
|
||||
|
||||
GCRoot(int N, const Constant *MD) : Num(N), StackOffset(-1), Metadata(MD) {}
|
||||
GCRoot(int N, const Constant *MD) : Num(N), Metadata(MD) {}
|
||||
};
|
||||
|
||||
/// Garbage collection metadata for a single function. Currently, this
|
||||
/// information only applies to GCStrategies which use GCRoot.
|
||||
class GCFunctionInfo {
|
||||
public:
|
||||
typedef std::vector<GCPoint>::iterator iterator;
|
||||
typedef std::vector<GCRoot>::iterator roots_iterator;
|
||||
typedef std::vector<GCRoot>::const_iterator live_iterator;
|
||||
using iterator = std::vector<GCPoint>::iterator;
|
||||
using roots_iterator = std::vector<GCRoot>::iterator;
|
||||
using live_iterator = std::vector<GCRoot>::const_iterator;
|
||||
|
||||
private:
|
||||
const Function &F;
|
||||
@ -99,11 +104,9 @@ class GCFunctionInfo {
|
||||
~GCFunctionInfo();
|
||||
|
||||
/// getFunction - Return the function to which this metadata applies.
|
||||
///
|
||||
const Function &getFunction() const { return F; }
|
||||
|
||||
/// getStrategy - Return the GC strategy for the function.
|
||||
///
|
||||
GCStrategy &getStrategy() { return S; }
|
||||
|
||||
/// addStackRoot - Registers a root that lives on the stack. Num is the
|
||||
@ -126,24 +129,20 @@ class GCFunctionInfo {
|
||||
}
|
||||
|
||||
/// getFrameSize/setFrameSize - Records the function's frame size.
|
||||
///
|
||||
uint64_t getFrameSize() const { return FrameSize; }
|
||||
void setFrameSize(uint64_t S) { FrameSize = S; }
|
||||
|
||||
/// begin/end - Iterators for safe points.
|
||||
///
|
||||
iterator begin() { return SafePoints.begin(); }
|
||||
iterator end() { return SafePoints.end(); }
|
||||
size_t size() const { return SafePoints.size(); }
|
||||
|
||||
/// roots_begin/roots_end - Iterators for all roots in the function.
|
||||
///
|
||||
roots_iterator roots_begin() { return Roots.begin(); }
|
||||
roots_iterator roots_end() { return Roots.end(); }
|
||||
size_t roots_size() const { return Roots.size(); }
|
||||
|
||||
/// live_begin/live_end - Iterators for live roots at a given safe point.
|
||||
///
|
||||
live_iterator live_begin(const iterator &p) { return roots_begin(); }
|
||||
live_iterator live_end(const iterator &p) { return roots_end(); }
|
||||
size_t live_size(const iterator &p) const { return roots_size(); }
|
||||
@ -166,7 +165,7 @@ class GCModuleInfo : public ImmutablePass {
|
||||
|
||||
/// List of per function info objects. In theory, Each of these
|
||||
/// may be associated with a different GC.
|
||||
typedef std::vector<std::unique_ptr<GCFunctionInfo>> FuncInfoVec;
|
||||
using FuncInfoVec = std::vector<std::unique_ptr<GCFunctionInfo>>;
|
||||
|
||||
FuncInfoVec::iterator funcinfo_begin() { return Functions.begin(); }
|
||||
FuncInfoVec::iterator funcinfo_end() { return Functions.end(); }
|
||||
@ -177,11 +176,11 @@ class GCModuleInfo : public ImmutablePass {
|
||||
|
||||
/// Non-owning map to bypass linear search when finding the GCFunctionInfo
|
||||
/// associated with a particular Function.
|
||||
typedef DenseMap<const Function *, GCFunctionInfo *> finfo_map_type;
|
||||
using finfo_map_type = DenseMap<const Function *, GCFunctionInfo *>;
|
||||
finfo_map_type FInfoMap;
|
||||
|
||||
public:
|
||||
typedef SmallVector<std::unique_ptr<GCStrategy>,1>::const_iterator iterator;
|
||||
using iterator = SmallVector<std::unique_ptr<GCStrategy>, 1>::const_iterator;
|
||||
|
||||
static char ID;
|
||||
|
||||
@ -202,6 +201,7 @@ class GCModuleInfo : public ImmutablePass {
|
||||
/// will soon change.
|
||||
GCFunctionInfo &getFunctionInfo(const Function &F);
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_CODEGEN_GCMETADATA_H
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===-- llvm/CodeGen/GCMetadataPrinter.h - Prints asm GC tables -*- C++ -*-===//
|
||||
//===- llvm/CodeGen/GCMetadataPrinter.h - Prints asm GC tables --*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -20,45 +20,48 @@
|
||||
#ifndef LLVM_CODEGEN_GCMETADATAPRINTER_H
|
||||
#define LLVM_CODEGEN_GCMETADATAPRINTER_H
|
||||
|
||||
#include "llvm/CodeGen/GCMetadata.h"
|
||||
#include "llvm/CodeGen/GCStrategy.h"
|
||||
#include "llvm/Support/Registry.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class AsmPrinter;
|
||||
class GCMetadataPrinter;
|
||||
class GCModuleInfo;
|
||||
class GCStrategy;
|
||||
class Module;
|
||||
|
||||
/// GCMetadataPrinterRegistry - The GC assembly printer registry uses all the
|
||||
/// defaults from Registry.
|
||||
typedef Registry<GCMetadataPrinter> GCMetadataPrinterRegistry;
|
||||
using GCMetadataPrinterRegistry = Registry<GCMetadataPrinter>;
|
||||
|
||||
/// GCMetadataPrinter - Emits GC metadata as assembly code. Instances are
|
||||
/// created, managed, and owned by the AsmPrinter.
|
||||
class GCMetadataPrinter {
|
||||
private:
|
||||
GCStrategy *S;
|
||||
friend class AsmPrinter;
|
||||
|
||||
GCStrategy *S;
|
||||
|
||||
protected:
|
||||
// May only be subclassed.
|
||||
GCMetadataPrinter();
|
||||
|
||||
private:
|
||||
public:
|
||||
GCMetadataPrinter(const GCMetadataPrinter &) = delete;
|
||||
GCMetadataPrinter &operator=(const GCMetadataPrinter &) = delete;
|
||||
virtual ~GCMetadataPrinter();
|
||||
|
||||
public:
|
||||
GCStrategy &getStrategy() { return *S; }
|
||||
|
||||
/// Called before the assembly for the module is generated by
|
||||
/// the AsmPrinter (but after target specific hooks.)
|
||||
virtual void beginAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
|
||||
|
||||
/// Called after the assembly for the module is generated by
|
||||
/// the AsmPrinter (but before target specific hooks)
|
||||
virtual void finishAssembly(Module &M, GCModuleInfo &Info, AsmPrinter &AP) {}
|
||||
|
||||
virtual ~GCMetadataPrinter();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_CODEGEN_GCMETADATAPRINTER_H
|
||||
|
@ -174,7 +174,7 @@ class GCStrategy {
|
||||
/// Note that to use a custom GCMetadataPrinter w/gc.roots, you must also
|
||||
/// register your GCMetadataPrinter subclass with the
|
||||
/// GCMetadataPrinterRegistery as well.
|
||||
typedef Registry<GCStrategy> GCRegistry;
|
||||
using GCRegistry = Registry<GCStrategy>;
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
||||
#define LLVM_CODEGEN_GLOBALISEL_INSTRUCTIONSELECTOR_H
|
||||
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include <cstdint>
|
||||
#include <bitset>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
||||
namespace llvm {
|
||||
|
@ -22,8 +22,8 @@
|
||||
#define LLVM_CODEGEN_GLOBALISEL_MACHINELEGALIZEHELPER_H
|
||||
|
||||
#include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
#include "llvm/CodeGen/LowLevelType.h"
|
||||
#include "llvm/CodeGen/MachineFunctionPass.h"
|
||||
|
||||
namespace llvm {
|
||||
// Forward declarations.
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
#include "llvm/CodeGen/GlobalISel/Types.h"
|
||||
|
||||
#include "llvm/CodeGen/LowLevelType.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/CodeGen/MachineInstrBuilder.h"
|
||||
#include "llvm/CodeGen/LowLevelType.h"
|
||||
#include "llvm/IR/Constants.h"
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
|
||||
|
@ -31,12 +31,13 @@ namespace llvm {
|
||||
class MachineBasicBlock;
|
||||
class MachineFunction;
|
||||
class MachineInstr;
|
||||
class MDNode;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// InsnRange - This is used to track range of instructions with identical
|
||||
/// lexical scope.
|
||||
///
|
||||
typedef std::pair<const MachineInstr *, const MachineInstr *> InsnRange;
|
||||
using InsnRange = std::pair<const MachineInstr *, const MachineInstr *>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// LexicalScope - This class is used to track scope information.
|
||||
|
@ -23,9 +23,9 @@
|
||||
|
||||
#include "llvm/ADT/ArrayRef.h"
|
||||
#include "llvm/ADT/IntEqClasses.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/CodeGen/SlotIndexes.h"
|
||||
#include "llvm/MC/LaneBitmask.h"
|
||||
#include "llvm/Support/Allocator.h"
|
||||
|
@ -16,9 +16,9 @@
|
||||
#define LLVM_CODEGEN_LIVEREGUNITS_H
|
||||
|
||||
#include "llvm/ADT/BitVector.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include "llvm/MC/LaneBitmask.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/Target/TargetRegisterInfo.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace llvm {
|
||||
|
@ -18,7 +18,6 @@
|
||||
#ifndef LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
|
||||
#define LLVM_CODEGEN_MIRPARSER_MIRPARSER_H
|
||||
|
||||
#include "llvm/CodeGen/MachineFunctionInitializer.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include <memory>
|
||||
@ -27,29 +26,30 @@ namespace llvm {
|
||||
|
||||
class StringRef;
|
||||
class MIRParserImpl;
|
||||
class MachineModuleInfo;
|
||||
class SMDiagnostic;
|
||||
|
||||
/// This class initializes machine functions by applying the state loaded from
|
||||
/// a MIR file.
|
||||
class MIRParser : public MachineFunctionInitializer {
|
||||
class MIRParser {
|
||||
std::unique_ptr<MIRParserImpl> Impl;
|
||||
|
||||
public:
|
||||
MIRParser(std::unique_ptr<MIRParserImpl> Impl);
|
||||
MIRParser(const MIRParser &) = delete;
|
||||
~MIRParser() override;
|
||||
~MIRParser();
|
||||
|
||||
/// Parse the optional LLVM IR module that's embedded in the MIR file.
|
||||
/// Parses the optional LLVM IR module in the MIR file.
|
||||
///
|
||||
/// A new, empty module is created if the LLVM IR isn't present.
|
||||
/// Returns null if a parsing error occurred.
|
||||
std::unique_ptr<Module> parseLLVMModule();
|
||||
/// \returns nullptr if a parsing error occurred.
|
||||
std::unique_ptr<Module> parseIRModule();
|
||||
|
||||
/// Initialize the machine function to the state that's described in the MIR
|
||||
/// file.
|
||||
/// \brief Parses MachineFunctions in the MIR file and add them to the given
|
||||
/// MachineModuleInfo \p MMI.
|
||||
///
|
||||
/// Return true if error occurred.
|
||||
bool initializeMachineFunction(MachineFunction &MF) override;
|
||||
/// \returns true if an error occurred.
|
||||
bool parseMachineFunctions(Module &M, MachineModuleInfo &MMI);
|
||||
};
|
||||
|
||||
/// This function is the main interface to the MIR serialization format parser.
|
||||
|
@ -72,6 +72,9 @@ template <> struct ScalarTraits<FlowStringValue> {
|
||||
|
||||
struct BlockStringValue {
|
||||
StringValue Value;
|
||||
bool operator==(const BlockStringValue &Other) const {
|
||||
return Value == Other.Value;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct BlockScalarTraits<BlockStringValue> {
|
||||
@ -146,6 +149,10 @@ struct VirtualRegisterDefinition {
|
||||
StringValue Class;
|
||||
StringValue PreferredRegister;
|
||||
// TODO: Serialize the target specific register hints.
|
||||
bool operator==(const VirtualRegisterDefinition &Other) const {
|
||||
return ID == Other.ID && Class == Other.Class &&
|
||||
PreferredRegister == Other.PreferredRegister;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<VirtualRegisterDefinition> {
|
||||
@ -162,6 +169,10 @@ template <> struct MappingTraits<VirtualRegisterDefinition> {
|
||||
struct MachineFunctionLiveIn {
|
||||
StringValue Register;
|
||||
StringValue VirtualRegister;
|
||||
bool operator==(const MachineFunctionLiveIn &Other) const {
|
||||
return Register == Other.Register &&
|
||||
VirtualRegister == Other.VirtualRegister;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<MachineFunctionLiveIn> {
|
||||
@ -196,6 +207,14 @@ struct MachineStackObject {
|
||||
StringValue DebugVar;
|
||||
StringValue DebugExpr;
|
||||
StringValue DebugLoc;
|
||||
bool operator==(const MachineStackObject &Other) const {
|
||||
return ID == Other.ID && Name == Other.Name && Type == Other.Type &&
|
||||
Offset == Other.Offset && Size == Other.Size &&
|
||||
Alignment == Other.Alignment &&
|
||||
CalleeSavedRegister == Other.CalleeSavedRegister &&
|
||||
LocalOffset == Other.LocalOffset && DebugVar == Other.DebugVar &&
|
||||
DebugExpr == Other.DebugExpr && DebugLoc == Other.DebugLoc;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct ScalarEnumerationTraits<MachineStackObject::ObjectType> {
|
||||
@ -214,13 +233,13 @@ template <> struct MappingTraits<MachineStackObject> {
|
||||
YamlIO.mapOptional(
|
||||
"type", Object.Type,
|
||||
MachineStackObject::DefaultType); // Don't print the default type.
|
||||
YamlIO.mapOptional("offset", Object.Offset);
|
||||
YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
|
||||
if (Object.Type != MachineStackObject::VariableSized)
|
||||
YamlIO.mapRequired("size", Object.Size);
|
||||
YamlIO.mapOptional("alignment", Object.Alignment);
|
||||
YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
|
||||
YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
|
||||
StringValue()); // Don't print it out when it's empty.
|
||||
YamlIO.mapOptional("local-offset", Object.LocalOffset);
|
||||
YamlIO.mapOptional("local-offset", Object.LocalOffset, Optional<int64_t>());
|
||||
YamlIO.mapOptional("di-variable", Object.DebugVar,
|
||||
StringValue()); // Don't print it out when it's empty.
|
||||
YamlIO.mapOptional("di-expression", Object.DebugExpr,
|
||||
@ -244,6 +263,12 @@ struct FixedMachineStackObject {
|
||||
bool IsImmutable = false;
|
||||
bool IsAliased = false;
|
||||
StringValue CalleeSavedRegister;
|
||||
bool operator==(const FixedMachineStackObject &Other) const {
|
||||
return ID == Other.ID && Type == Other.Type && Offset == Other.Offset &&
|
||||
Size == Other.Size && Alignment == Other.Alignment &&
|
||||
IsImmutable == Other.IsImmutable && IsAliased == Other.IsAliased &&
|
||||
CalleeSavedRegister == Other.CalleeSavedRegister;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
@ -261,12 +286,12 @@ template <> struct MappingTraits<FixedMachineStackObject> {
|
||||
YamlIO.mapOptional(
|
||||
"type", Object.Type,
|
||||
FixedMachineStackObject::DefaultType); // Don't print the default type.
|
||||
YamlIO.mapOptional("offset", Object.Offset);
|
||||
YamlIO.mapOptional("size", Object.Size);
|
||||
YamlIO.mapOptional("alignment", Object.Alignment);
|
||||
YamlIO.mapOptional("offset", Object.Offset, (int64_t)0);
|
||||
YamlIO.mapOptional("size", Object.Size, (uint64_t)0);
|
||||
YamlIO.mapOptional("alignment", Object.Alignment, (unsigned)0);
|
||||
if (Object.Type != FixedMachineStackObject::SpillSlot) {
|
||||
YamlIO.mapOptional("isImmutable", Object.IsImmutable);
|
||||
YamlIO.mapOptional("isAliased", Object.IsAliased);
|
||||
YamlIO.mapOptional("isImmutable", Object.IsImmutable, false);
|
||||
YamlIO.mapOptional("isAliased", Object.IsAliased, false);
|
||||
}
|
||||
YamlIO.mapOptional("callee-saved-register", Object.CalleeSavedRegister,
|
||||
StringValue()); // Don't print it out when it's empty.
|
||||
@ -279,13 +304,17 @@ struct MachineConstantPoolValue {
|
||||
UnsignedValue ID;
|
||||
StringValue Value;
|
||||
unsigned Alignment = 0;
|
||||
bool operator==(const MachineConstantPoolValue &Other) const {
|
||||
return ID == Other.ID && Value == Other.Value &&
|
||||
Alignment == Other.Alignment;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<MachineConstantPoolValue> {
|
||||
static void mapping(IO &YamlIO, MachineConstantPoolValue &Constant) {
|
||||
YamlIO.mapRequired("id", Constant.ID);
|
||||
YamlIO.mapOptional("value", Constant.Value);
|
||||
YamlIO.mapOptional("alignment", Constant.Alignment);
|
||||
YamlIO.mapOptional("value", Constant.Value, StringValue());
|
||||
YamlIO.mapOptional("alignment", Constant.Alignment, (unsigned)0);
|
||||
}
|
||||
};
|
||||
|
||||
@ -293,16 +322,22 @@ struct MachineJumpTable {
|
||||
struct Entry {
|
||||
UnsignedValue ID;
|
||||
std::vector<FlowStringValue> Blocks;
|
||||
bool operator==(const Entry &Other) const {
|
||||
return ID == Other.ID && Blocks == Other.Blocks;
|
||||
}
|
||||
};
|
||||
|
||||
MachineJumpTableInfo::JTEntryKind Kind = MachineJumpTableInfo::EK_Custom32;
|
||||
std::vector<Entry> Entries;
|
||||
bool operator==(const MachineJumpTable &Other) const {
|
||||
return Kind == Other.Kind && Entries == Other.Entries;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<MachineJumpTable::Entry> {
|
||||
static void mapping(IO &YamlIO, MachineJumpTable::Entry &Entry) {
|
||||
YamlIO.mapRequired("id", Entry.ID);
|
||||
YamlIO.mapOptional("blocks", Entry.Blocks);
|
||||
YamlIO.mapOptional("blocks", Entry.Blocks, std::vector<FlowStringValue>());
|
||||
}
|
||||
};
|
||||
|
||||
@ -322,7 +357,8 @@ namespace yaml {
|
||||
template <> struct MappingTraits<MachineJumpTable> {
|
||||
static void mapping(IO &YamlIO, MachineJumpTable &JT) {
|
||||
YamlIO.mapRequired("kind", JT.Kind);
|
||||
YamlIO.mapOptional("entries", JT.Entries);
|
||||
YamlIO.mapOptional("entries", JT.Entries,
|
||||
std::vector<MachineJumpTable::Entry>());
|
||||
}
|
||||
};
|
||||
|
||||
@ -351,25 +387,43 @@ struct MachineFrameInfo {
|
||||
bool HasMustTailInVarArgFunc = false;
|
||||
StringValue SavePoint;
|
||||
StringValue RestorePoint;
|
||||
bool operator==(const MachineFrameInfo &Other) const {
|
||||
return IsFrameAddressTaken == Other.IsFrameAddressTaken &&
|
||||
IsReturnAddressTaken == Other.IsReturnAddressTaken &&
|
||||
HasStackMap == Other.HasStackMap &&
|
||||
HasPatchPoint == Other.HasPatchPoint &&
|
||||
StackSize == Other.StackSize &&
|
||||
OffsetAdjustment == Other.OffsetAdjustment &&
|
||||
MaxAlignment == Other.MaxAlignment &&
|
||||
AdjustsStack == Other.AdjustsStack && HasCalls == Other.HasCalls &&
|
||||
StackProtector == Other.StackProtector &&
|
||||
MaxCallFrameSize == Other.MaxCallFrameSize &&
|
||||
HasOpaqueSPAdjustment == Other.HasOpaqueSPAdjustment &&
|
||||
HasVAStart == Other.HasVAStart &&
|
||||
HasMustTailInVarArgFunc == Other.HasMustTailInVarArgFunc &&
|
||||
SavePoint == Other.SavePoint && RestorePoint == Other.RestorePoint;
|
||||
}
|
||||
};
|
||||
|
||||
template <> struct MappingTraits<MachineFrameInfo> {
|
||||
static void mapping(IO &YamlIO, MachineFrameInfo &MFI) {
|
||||
YamlIO.mapOptional("isFrameAddressTaken", MFI.IsFrameAddressTaken);
|
||||
YamlIO.mapOptional("isReturnAddressTaken", MFI.IsReturnAddressTaken);
|
||||
YamlIO.mapOptional("hasStackMap", MFI.HasStackMap);
|
||||
YamlIO.mapOptional("hasPatchPoint", MFI.HasPatchPoint);
|
||||
YamlIO.mapOptional("stackSize", MFI.StackSize);
|
||||
YamlIO.mapOptional("offsetAdjustment", MFI.OffsetAdjustment);
|
||||
YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment);
|
||||
YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack);
|
||||
YamlIO.mapOptional("hasCalls", MFI.HasCalls);
|
||||
YamlIO.mapOptional("isFrameAddressTaken", MFI.IsFrameAddressTaken, false);
|
||||
YamlIO.mapOptional("isReturnAddressTaken", MFI.IsReturnAddressTaken, false);
|
||||
YamlIO.mapOptional("hasStackMap", MFI.HasStackMap, false);
|
||||
YamlIO.mapOptional("hasPatchPoint", MFI.HasPatchPoint, false);
|
||||
YamlIO.mapOptional("stackSize", MFI.StackSize, (uint64_t)0);
|
||||
YamlIO.mapOptional("offsetAdjustment", MFI.OffsetAdjustment, (int)0);
|
||||
YamlIO.mapOptional("maxAlignment", MFI.MaxAlignment, (unsigned)0);
|
||||
YamlIO.mapOptional("adjustsStack", MFI.AdjustsStack, false);
|
||||
YamlIO.mapOptional("hasCalls", MFI.HasCalls, false);
|
||||
YamlIO.mapOptional("stackProtector", MFI.StackProtector,
|
||||
StringValue()); // Don't print it out when it's empty.
|
||||
YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize, ~0u);
|
||||
YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment);
|
||||
YamlIO.mapOptional("hasVAStart", MFI.HasVAStart);
|
||||
YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc);
|
||||
YamlIO.mapOptional("maxCallFrameSize", MFI.MaxCallFrameSize, (unsigned)~0);
|
||||
YamlIO.mapOptional("hasOpaqueSPAdjustment", MFI.HasOpaqueSPAdjustment,
|
||||
false);
|
||||
YamlIO.mapOptional("hasVAStart", MFI.HasVAStart, false);
|
||||
YamlIO.mapOptional("hasMustTailInVarArgFunc", MFI.HasMustTailInVarArgFunc,
|
||||
false);
|
||||
YamlIO.mapOptional("savePoint", MFI.SavePoint,
|
||||
StringValue()); // Don't print it out when it's empty.
|
||||
YamlIO.mapOptional("restorePoint", MFI.RestorePoint,
|
||||
@ -403,22 +457,28 @@ struct MachineFunction {
|
||||
template <> struct MappingTraits<MachineFunction> {
|
||||
static void mapping(IO &YamlIO, MachineFunction &MF) {
|
||||
YamlIO.mapRequired("name", MF.Name);
|
||||
YamlIO.mapOptional("alignment", MF.Alignment);
|
||||
YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice);
|
||||
YamlIO.mapOptional("legalized", MF.Legalized);
|
||||
YamlIO.mapOptional("regBankSelected", MF.RegBankSelected);
|
||||
YamlIO.mapOptional("selected", MF.Selected);
|
||||
YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness);
|
||||
YamlIO.mapOptional("registers", MF.VirtualRegisters);
|
||||
YamlIO.mapOptional("liveins", MF.LiveIns);
|
||||
YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters);
|
||||
YamlIO.mapOptional("frameInfo", MF.FrameInfo);
|
||||
YamlIO.mapOptional("fixedStack", MF.FixedStackObjects);
|
||||
YamlIO.mapOptional("stack", MF.StackObjects);
|
||||
YamlIO.mapOptional("constants", MF.Constants);
|
||||
YamlIO.mapOptional("alignment", MF.Alignment, (unsigned)0);
|
||||
YamlIO.mapOptional("exposesReturnsTwice", MF.ExposesReturnsTwice, false);
|
||||
YamlIO.mapOptional("legalized", MF.Legalized, false);
|
||||
YamlIO.mapOptional("regBankSelected", MF.RegBankSelected, false);
|
||||
YamlIO.mapOptional("selected", MF.Selected, false);
|
||||
YamlIO.mapOptional("tracksRegLiveness", MF.TracksRegLiveness, false);
|
||||
YamlIO.mapOptional("registers", MF.VirtualRegisters,
|
||||
std::vector<VirtualRegisterDefinition>());
|
||||
YamlIO.mapOptional("liveins", MF.LiveIns,
|
||||
std::vector<MachineFunctionLiveIn>());
|
||||
YamlIO.mapOptional("calleeSavedRegisters", MF.CalleeSavedRegisters,
|
||||
Optional<std::vector<FlowStringValue>>());
|
||||
YamlIO.mapOptional("frameInfo", MF.FrameInfo, MachineFrameInfo());
|
||||
YamlIO.mapOptional("fixedStack", MF.FixedStackObjects,
|
||||
std::vector<FixedMachineStackObject>());
|
||||
YamlIO.mapOptional("stack", MF.StackObjects,
|
||||
std::vector<MachineStackObject>());
|
||||
YamlIO.mapOptional("constants", MF.Constants,
|
||||
std::vector<MachineConstantPoolValue>());
|
||||
if (!YamlIO.outputting() || !MF.JumpTableInfo.Entries.empty())
|
||||
YamlIO.mapOptional("jumpTable", MF.JumpTableInfo);
|
||||
YamlIO.mapOptional("body", MF.Body);
|
||||
YamlIO.mapOptional("jumpTable", MF.JumpTableInfo, MachineJumpTable());
|
||||
YamlIO.mapOptional("body", MF.Body, BlockStringValue());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -19,12 +19,12 @@
|
||||
#include "llvm/ADT/ilist_node.h"
|
||||
#include "llvm/ADT/iterator_range.h"
|
||||
#include "llvm/ADT/simple_ilist.h"
|
||||
#include "llvm/CodeGen/MachineInstrBundleIterator.h"
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
#include "llvm/CodeGen/MachineInstrBundleIterator.h"
|
||||
#include "llvm/IR/DebugLoc.h"
|
||||
#include "llvm/Support/BranchProbability.h"
|
||||
#include "llvm/MC/LaneBitmask.h"
|
||||
#include "llvm/MC/MCRegisterInfo.h"
|
||||
#include "llvm/Support/BranchProbability.h"
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
|
@ -22,11 +22,11 @@
|
||||
#include "llvm/ADT/BitVector.h"
|
||||
#include "llvm/ADT/DenseMap.h"
|
||||
#include "llvm/ADT/GraphTraits.h"
|
||||
#include "llvm/ADT/ilist.h"
|
||||
#include "llvm/ADT/iterator.h"
|
||||
#include "llvm/ADT/Optional.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/ADT/ilist.h"
|
||||
#include "llvm/ADT/iterator.h"
|
||||
#include "llvm/Analysis/EHPersonalities.h"
|
||||
#include "llvm/CodeGen/MachineBasicBlock.h"
|
||||
#include "llvm/CodeGen/MachineInstr.h"
|
||||
|
@ -1,38 +0,0 @@
|
||||
//=- MachineFunctionInitializer.h - machine function initializer --*- C++ -*-=//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file declares an interface that allows custom machine function
|
||||
// initialization.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CODEGEN_MACHINEFUNCTIONINITIALIZER_H
|
||||
#define LLVM_CODEGEN_MACHINEFUNCTIONINITIALIZER_H
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class MachineFunction;
|
||||
|
||||
/// This interface provides a way to initialize machine functions after they are
|
||||
/// created by the machine function analysis pass.
|
||||
class MachineFunctionInitializer {
|
||||
virtual void anchor();
|
||||
|
||||
public:
|
||||
virtual ~MachineFunctionInitializer() = default;
|
||||
|
||||
/// Initialize the machine function.
|
||||
///
|
||||
/// Return true if error occurred.
|
||||
virtual bool initializeMachineFunction(MachineFunction &MF) = 0;
|
||||
};
|
||||
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_CODEGEN_MACHINEFUNCTIONINITIALIZER_H
|
@ -19,8 +19,8 @@
|
||||
#ifndef LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
|
||||
#define LLVM_CODEGEN_MACHINEFUNCTIONPASS_H
|
||||
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/CodeGen/MachineFunction.h"
|
||||
#include "llvm/Pass.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
#include "llvm/CodeGen/PseudoSourceValue.h"
|
||||
#include "llvm/IR/Instructions.h"
|
||||
#include "llvm/IR/Metadata.h"
|
||||
#include "llvm/IR/Value.h" // PointerLikeTypeTraits<Value*>
|
||||
#include "llvm/IR/Value.h" // PointerLikeTypeTraits<Value*>
|
||||
#include "llvm/Support/AtomicOrdering.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
|
||||
|
@ -47,7 +47,6 @@ class BasicBlock;
|
||||
class CallInst;
|
||||
class Function;
|
||||
class MachineFunction;
|
||||
class MachineFunctionInitializer;
|
||||
class MMIAddrLabelMap;
|
||||
class Module;
|
||||
class TargetMachine;
|
||||
@ -126,7 +125,6 @@ class MachineModuleInfo : public ImmutablePass {
|
||||
/// comments in lib/Target/X86/X86FrameLowering.cpp for more details.
|
||||
bool UsesMorestackAddr;
|
||||
|
||||
MachineFunctionInitializer *MFInitializer;
|
||||
/// Maps IR Functions to their corresponding MachineFunctions.
|
||||
DenseMap<const Function*, std::unique_ptr<MachineFunction>> MachineFunctions;
|
||||
/// Next unique number available for a MachineFunction.
|
||||
@ -150,14 +148,13 @@ class MachineModuleInfo : public ImmutablePass {
|
||||
void setModule(const Module *M) { TheModule = M; }
|
||||
const Module *getModule() const { return TheModule; }
|
||||
|
||||
void setMachineFunctionInitializer(MachineFunctionInitializer *MFInit) {
|
||||
MFInitializer = MFInit;
|
||||
}
|
||||
|
||||
/// Returns the MachineFunction constructed for the IR function \p F.
|
||||
/// Creates a new MachineFunction and runs the MachineFunctionInitializer
|
||||
/// if none exists yet.
|
||||
MachineFunction &getMachineFunction(const Function &F);
|
||||
/// Creates a new MachineFunction if none exists yet.
|
||||
MachineFunction &getOrCreateMachineFunction(const Function &F);
|
||||
|
||||
/// \bried Returns the MachineFunction associated to IR function \p F if there
|
||||
/// is one, otherwise nullptr.
|
||||
MachineFunction *getMachineFunction(const Function &F) const;
|
||||
|
||||
/// Delete the MachineFunction \p MF and reset the link in the IR Function to
|
||||
/// Machine Function map.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user