Skip to content

Commit 3c571b3

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6-beta.1
2 parents aec685e + ba2040d commit 3c571b3

File tree

80 files changed

+928
-178
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+928
-178
lines changed

clang/lib/Basic/Targets/AMDGPU.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ static const char *const DataLayoutStringR600 =
3333

3434
static const char *const DataLayoutStringAMDGCN =
3535
"e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
36-
"-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:"
37-
"32-v48:64-v96:128"
38-
"-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1"
39-
"-ni:7:8:9";
36+
"-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-"
37+
"v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-"
38+
"v2048:2048-n32:64-S32-A5-G1-ni:7:8:9";
4039

4140
const LangASMap AMDGPUTargetInfo::AMDGPUDefIsGenMap = {
4241
llvm::AMDGPUAS::FLAT_ADDRESS, // Default

clang/test/CodeGen/target-data.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,12 @@
176176

177177
// RUN: %clang_cc1 -triple amdgcn-unknown -target-cpu hawaii -o - -emit-llvm %s \
178178
// RUN: | FileCheck %s -check-prefix=R600SI
179-
// R600SI: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
179+
// R600SI: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
180180

181181
// Test default -target-cpu
182182
// RUN: %clang_cc1 -triple amdgcn-unknown -o - -emit-llvm %s \
183183
// RUN: | FileCheck %s -check-prefix=R600SIDefault
184-
// R600SIDefault: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
184+
// R600SIDefault: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
185185

186186
// RUN: %clang_cc1 -triple arm64-unknown -o - -emit-llvm %s | \
187187
// RUN: FileCheck %s -check-prefix=AARCH64
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// RUN: %clang_cc1 %s -O0 -triple amdgcn -emit-llvm -o - | FileCheck %s
22
// RUN: %clang_cc1 %s -O0 -triple amdgcn---opencl -emit-llvm -o - | FileCheck %s
33

4-
// CHECK: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
4+
// CHECK: target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-p7:160:256:256:32-p8:128:128:128:48-p9:192:256:256:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1-ni:7:8:9"
55
void foo(void) {}

llvm/docs/GlobalISel/GenericOpcode.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,15 @@ Convert a pointer to an integer.
169169
170170
%1:_(s32) = G_PTRTOINT %0:_(p0)
171171
172+
G_PTRTOADDR
173+
^^^^^^^^^^^
174+
175+
Extract the address part of a pointer to an integer.
176+
177+
.. code-block:: none
178+
179+
%1:_(s32) = G_PTRTOADDR %0:_(p0)
180+
172181
G_BITCAST
173182
^^^^^^^^^
174183

llvm/docs/LangRef.rst

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12428,12 +12428,15 @@ Semantics:
1242812428
""""""""""
1242912429

1243012430
The '``ptrtoint``' instruction converts ``value`` to integer type
12431-
``ty2`` by interpreting the pointer value as an integer and either
12432-
truncating or zero extending that value to the size of the integer type.
12431+
``ty2`` by interpreting the all pointer representation bits as an integer
12432+
(equivalent to a ``bitcast``) and either truncating or zero extending that value
12433+
to the size of the integer type.
1243312434
If ``value`` is smaller than ``ty2`` then a zero extension is done. If
1243412435
``value`` is larger than ``ty2`` then a truncation is done. If they are
1243512436
the same size, then nothing is done (*no-op cast*) other than a type
1243612437
change.
12438+
The ``ptrtoint`` always :ref:`captures address and provenance <pointercapture>`
12439+
of the pointer argument.
1243712440

1243812441
Example:
1243912442
""""""""
@@ -12444,6 +12447,61 @@ Example:
1244412447
%Y = ptrtoint ptr %P to i64 ; yields zero extension on 32-bit architecture
1244512448
%Z = ptrtoint <4 x ptr> %P to <4 x i64>; yields vector zero extension for a vector of addresses on 32-bit architecture
1244612449

12450+
.. _i_ptrtoaddr:
12451+
12452+
'``ptrtoaddr .. to``' Instruction
12453+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12454+
12455+
Syntax:
12456+
"""""""
12457+
12458+
::
12459+
12460+
<result> = ptrtoaddr <ty> <value> to <ty2> ; yields ty2
12461+
12462+
Overview:
12463+
"""""""""
12464+
12465+
The '``ptrtoaddr``' instruction converts the pointer or a vector of
12466+
pointers ``value`` to the underlying integer address (or vector of integers) of
12467+
type ``ty2``. This is different from :ref:`ptrtoint <i_ptrtoint>` in that it
12468+
only operates on the index bits of the pointer and ignores all other bits.
12469+
12470+
Arguments:
12471+
""""""""""
12472+
12473+
The '``ptrtoaddr``' instruction takes a ``value`` to cast, which must be
12474+
a value of type :ref:`pointer <t_pointer>` or a vector of pointers, and a
12475+
type to cast it to ``ty2``, which must be an :ref:`integer <t_integer>` or
12476+
a vector of integers type.
12477+
12478+
Semantics:
12479+
""""""""""
12480+
12481+
The '``ptrtoaddr``' instruction converts ``value`` to integer type
12482+
``ty2`` by interpreting the lowest index-width pointer representation bits as an
12483+
integer and either truncating or zero extending that value to the size of the
12484+
integer type.
12485+
If the address of ``value`` is smaller than ``ty2`` then a zero extension is
12486+
done. If the address of ``value`` is larger than ``ty2`` then a truncation is
12487+
done. If the address size and the pointer representation size are the same and
12488+
``value`` and ``ty2`` are the same size, then nothing is done (*no-op cast*)
12489+
other than a type change.
12490+
12491+
The ``ptrtoaddr`` always :ref:`captures the address (but not provenance) <pointercapture>`
12492+
of the pointer argument.
12493+
12494+
Example:
12495+
""""""""
12496+
This example assumes pointers in address space 1 are 64 bits in size with an
12497+
address width of 32 bits (``p1:64:64:64:32`` :ref:`datalayout string<langref_datalayout>`)
12498+
.. code-block:: llvm
12499+
12500+
%X = ptrtoaddr ptr addrspace(1) %P to i8 ; extracts low 32 bits and truncates
12501+
%Y = ptrtoaddr ptr addrspace(1) %P to i64 ; extracts low 32 bits and zero extends
12502+
%Z = ptrtoaddr <4 x ptr addrspace(1)> %P to <4 x i64>; yields vector zero extension of low 32 bits for each pointer
12503+
12504+
1244712505
.. _i_inttoptr:
1244812506

1244912507
'``inttoptr .. to``' Instruction
@@ -12488,6 +12546,9 @@ of the integer ``value``. If ``value`` is larger than the size of a
1248812546
pointer then a truncation is done. If ``value`` is smaller than the size
1248912547
of a pointer then a zero extension is done. If they are the same size,
1249012548
nothing is done (*no-op cast*).
12549+
The behavior is equivalent to a ``bitcast``, however, the resulting value is not
12550+
guaranteed to be dereferenceable (e.g. if the result type is a
12551+
:ref:`non-integral pointers <nointptrtype>`).
1249112552

1249212553
Example:
1249312554
""""""""

llvm/include/llvm-c/Core.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ typedef enum {
110110
LLVMFPTrunc = 37,
111111
LLVMFPExt = 38,
112112
LLVMPtrToInt = 39,
113+
LLVMPtrToAddr = 69,
113114
LLVMIntToPtr = 40,
114115
LLVMBitCast = 41,
115116
LLVMAddrSpaceCast = 60,

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,12 @@ class TargetTransformInfoImplBase {
732732
return 0;
733733
break;
734734
}
735+
case Instruction::PtrToAddr: {
736+
unsigned DstSize = Dst->getScalarSizeInBits();
737+
if (DL.isLegalInteger(DstSize) && DstSize >= DL.getAddressSizeInBits(Src))
738+
return 0;
739+
break;
740+
}
735741
case Instruction::PtrToInt: {
736742
unsigned DstSize = Dst->getScalarSizeInBits();
737743
if (DL.isLegalInteger(DstSize) &&
@@ -1438,6 +1444,7 @@ class TargetTransformInfoImplCRTPBase : public TargetTransformInfoImplBase {
14381444
Op2Info, Operands, I);
14391445
}
14401446
case Instruction::IntToPtr:
1447+
case Instruction::PtrToAddr:
14411448
case Instruction::PtrToInt:
14421449
case Instruction::SIToFP:
14431450
case Instruction::UIToFP:

llvm/include/llvm/AsmParser/LLToken.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ enum Kind {
318318
kw_fptoui,
319319
kw_fptosi,
320320
kw_inttoptr,
321+
kw_ptrtoaddr,
321322
kw_ptrtoint,
322323
kw_bitcast,
323324
kw_addrspacecast,

llvm/include/llvm/Bitcode/LLVMBitCodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,8 @@ enum CastOpcodes {
456456
CAST_PTRTOINT = 9,
457457
CAST_INTTOPTR = 10,
458458
CAST_BITCAST = 11,
459-
CAST_ADDRSPACECAST = 12
459+
CAST_ADDRSPACECAST = 12,
460+
CAST_PTRTOADDR = 13,
460461
};
461462

462463
/// UnaryOpcodes - These are values used in the bitcode files to encode which

llvm/include/llvm/CodeGen/GlobalISel/GenericMachineInstrs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,6 +870,7 @@ class GCastOp : public GenericMachineInstr {
870870
case TargetOpcode::G_FPTOUI_SAT:
871871
case TargetOpcode::G_FPTRUNC:
872872
case TargetOpcode::G_INTTOPTR:
873+
case TargetOpcode::G_PTRTOADDR:
873874
case TargetOpcode::G_PTRTOINT:
874875
case TargetOpcode::G_SEXT:
875876
case TargetOpcode::G_SITOFP:

0 commit comments

Comments
 (0)