Skip to content

Commit 0fea027

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.6-beta.1
2 parents c2f0af5 + de7d14c commit 0fea027

Some content is hidden

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

47 files changed

+903
-85
lines changed

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: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12466,6 +12466,61 @@ Example:
1246612466
%Y = ptrtoint ptr %P to i64 ; yields zero extension on 32-bit architecture
1246712467
%Z = ptrtoint <4 x ptr> %P to <4 x i64>; yields vector zero extension for a vector of addresses on 32-bit architecture
1246812468

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

1247112526
'``inttoptr .. to``' Instruction

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:

llvm/include/llvm/CodeGen/GlobalISel/IRTranslator.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,9 @@ class IRTranslator : public MachineFunctionPass {
486486
bool translatePtrToInt(const User &U, MachineIRBuilder &MIRBuilder) {
487487
return translateCast(TargetOpcode::G_PTRTOINT, U, MIRBuilder);
488488
}
489+
bool translatePtrToAddr(const User &U, MachineIRBuilder &MIRBuilder) {
490+
return translateCast(TargetOpcode::G_PTRTOADDR, U, MIRBuilder);
491+
}
489492
bool translateTrunc(const User &U, MachineIRBuilder &MIRBuilder) {
490493
return translateCast(TargetOpcode::G_TRUNC, U, MIRBuilder);
491494
}

llvm/include/llvm/CodeGen/GlobalISel/LegalizerHelper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,7 @@ class LegalizerHelper {
429429
LLVM_ABI LegalizeResult lowerFunnelShift(MachineInstr &MI);
430430
LLVM_ABI LegalizeResult lowerEXT(MachineInstr &MI);
431431
LLVM_ABI LegalizeResult lowerTRUNC(MachineInstr &MI);
432+
LLVM_ABI LegalizeResult lowerPTRTOADDR(MachineInstr &MI);
432433
LLVM_ABI LegalizeResult lowerRotateWithReverseRotate(MachineInstr &MI);
433434
LLVM_ABI LegalizeResult lowerRotate(MachineInstr &MI);
434435

llvm/include/llvm/CodeGen/GlobalISel/MachineIRBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,11 @@ class LLVM_ABI MachineIRBuilder {
715715
return buildInstr(TargetOpcode::G_PTRTOINT, {Dst}, {Src});
716716
}
717717

718+
/// Build and insert a G_PTRTOADDR instruction.
719+
MachineInstrBuilder buildPtrToAddr(const DstOp &Dst, const SrcOp &Src) {
720+
return buildInstr(TargetOpcode::G_PTRTOADDR, {Dst}, {Src});
721+
}
722+
718723
/// Build and insert a G_INTTOPTR instruction.
719724
MachineInstrBuilder buildIntToPtr(const DstOp &Dst, const SrcOp &Src) {
720725
return buildInstr(TargetOpcode::G_INTTOPTR, {Dst}, {Src});

llvm/include/llvm/IR/InstVisitor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ class InstVisitor {
183183
RetTy visitUIToFPInst(UIToFPInst &I) { DELEGATE(CastInst);}
184184
RetTy visitSIToFPInst(SIToFPInst &I) { DELEGATE(CastInst);}
185185
RetTy visitPtrToIntInst(PtrToIntInst &I) { DELEGATE(CastInst);}
186+
RetTy visitPtrToAddrInst(PtrToAddrInst &I) { DELEGATE(CastInst);}
186187
RetTy visitIntToPtrInst(IntToPtrInst &I) { DELEGATE(CastInst);}
187188
RetTy visitBitCastInst(BitCastInst &I) { DELEGATE(CastInst);}
188189
RetTy visitAddrSpaceCastInst(AddrSpaceCastInst &I) { DELEGATE(CastInst);}

llvm/include/llvm/IR/Instruction.def

Lines changed: 27 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -190,35 +190,36 @@ HANDLE_CAST_INST(43, UIToFP , UIToFPInst ) // UInt -> floating point
190190
HANDLE_CAST_INST(44, SIToFP , SIToFPInst ) // SInt -> floating point
191191
HANDLE_CAST_INST(45, FPTrunc , FPTruncInst ) // Truncate floating point
192192
HANDLE_CAST_INST(46, FPExt , FPExtInst ) // Extend floating point
193-
HANDLE_CAST_INST(47, PtrToInt, PtrToIntInst) // Pointer -> Integer
194-
HANDLE_CAST_INST(48, IntToPtr, IntToPtrInst) // Integer -> Pointer
195-
HANDLE_CAST_INST(49, BitCast , BitCastInst ) // Type cast
196-
HANDLE_CAST_INST(50, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast
197-
LAST_CAST_INST(50)
193+
HANDLE_CAST_INST(47, PtrToInt, PtrToIntInst) // Pointer -> Integer (bitcast)
194+
HANDLE_CAST_INST(48, PtrToAddr, PtrToAddrInst) // Pointer -> Address
195+
HANDLE_CAST_INST(49, IntToPtr, IntToPtrInst) // Integer -> Pointer
196+
HANDLE_CAST_INST(50, BitCast , BitCastInst ) // Type cast
197+
HANDLE_CAST_INST(51, AddrSpaceCast, AddrSpaceCastInst) // addrspace cast
198+
LAST_CAST_INST(51)
198199

199-
FIRST_FUNCLETPAD_INST(51)
200-
HANDLE_FUNCLETPAD_INST(51, CleanupPad, CleanupPadInst)
201-
HANDLE_FUNCLETPAD_INST(52, CatchPad , CatchPadInst)
202-
LAST_FUNCLETPAD_INST(52)
200+
FIRST_FUNCLETPAD_INST(52)
201+
HANDLE_FUNCLETPAD_INST(52, CleanupPad, CleanupPadInst)
202+
HANDLE_FUNCLETPAD_INST(53, CatchPad , CatchPadInst)
203+
LAST_FUNCLETPAD_INST(53)
203204

204205
// Other operators...
205-
FIRST_OTHER_INST(53)
206-
HANDLE_OTHER_INST(53, ICmp , ICmpInst ) // Integer comparison instruction
207-
HANDLE_OTHER_INST(54, FCmp , FCmpInst ) // Floating point comparison instr.
208-
HANDLE_OTHER_INST(55, PHI , PHINode ) // PHI node instruction
209-
HANDLE_OTHER_INST(56, Call , CallInst ) // Call a function
210-
HANDLE_OTHER_INST(57, Select , SelectInst ) // select instruction
211-
HANDLE_USER_INST (58, UserOp1, Instruction) // May be used internally in a pass
212-
HANDLE_USER_INST (59, UserOp2, Instruction) // Internal to passes only
213-
HANDLE_OTHER_INST(60, VAArg , VAArgInst ) // vaarg instruction
214-
HANDLE_OTHER_INST(61, ExtractElement, ExtractElementInst)// extract from vector
215-
HANDLE_OTHER_INST(62, InsertElement, InsertElementInst) // insert into vector
216-
HANDLE_OTHER_INST(63, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
217-
HANDLE_OTHER_INST(64, ExtractValue, ExtractValueInst)// extract from aggregate
218-
HANDLE_OTHER_INST(65, InsertValue, InsertValueInst) // insert into aggregate
219-
HANDLE_OTHER_INST(66, LandingPad, LandingPadInst) // Landing pad instruction.
220-
HANDLE_OTHER_INST(67, Freeze, FreezeInst) // Freeze instruction.
221-
LAST_OTHER_INST(67)
206+
FIRST_OTHER_INST(54)
207+
HANDLE_OTHER_INST(54, ICmp , ICmpInst ) // Integer comparison instruction
208+
HANDLE_OTHER_INST(55, FCmp , FCmpInst ) // Floating point comparison instr.
209+
HANDLE_OTHER_INST(56, PHI , PHINode ) // PHI node instruction
210+
HANDLE_OTHER_INST(57, Call , CallInst ) // Call a function
211+
HANDLE_OTHER_INST(58, Select , SelectInst ) // select instruction
212+
HANDLE_USER_INST (59, UserOp1, Instruction) // May be used internally in a pass
213+
HANDLE_USER_INST (60, UserOp2, Instruction) // Internal to passes only
214+
HANDLE_OTHER_INST(61, VAArg , VAArgInst ) // vaarg instruction
215+
HANDLE_OTHER_INST(62, ExtractElement, ExtractElementInst)// extract from vector
216+
HANDLE_OTHER_INST(63, InsertElement, InsertElementInst) // insert into vector
217+
HANDLE_OTHER_INST(64, ShuffleVector, ShuffleVectorInst) // shuffle two vectors.
218+
HANDLE_OTHER_INST(65, ExtractValue, ExtractValueInst)// extract from aggregate
219+
HANDLE_OTHER_INST(66, InsertValue, InsertValueInst) // insert into aggregate
220+
HANDLE_OTHER_INST(67, LandingPad, LandingPadInst) // Landing pad instruction.
221+
HANDLE_OTHER_INST(68, Freeze, FreezeInst) // Freeze instruction.
222+
LAST_OTHER_INST(68)
222223

223224
#undef FIRST_TERM_INST
224225
#undef HANDLE_TERM_INST

llvm/include/llvm/IR/Instructions.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4949,6 +4949,46 @@ class PtrToIntInst : public CastInst {
49494949
}
49504950
};
49514951

4952+
/// This class represents a cast from a pointer to an address (non-capturing
4953+
/// ptrtoint).
4954+
class PtrToAddrInst : public CastInst {
4955+
protected:
4956+
// Note: Instruction needs to be a friend here to call cloneImpl.
4957+
friend class Instruction;
4958+
4959+
/// Clone an identical PtrToIntInst.
4960+
PtrToAddrInst *cloneImpl() const;
4961+
4962+
public:
4963+
/// Constructor with insert-before-instruction semantics
4964+
PtrToAddrInst(Value *S, ///< The value to be converted
4965+
Type *Ty, ///< The type to convert to
4966+
const Twine &NameStr = "", ///< A name for the new instruction
4967+
InsertPosition InsertBefore =
4968+
nullptr ///< Where to insert the new instruction
4969+
);
4970+
4971+
/// Gets the pointer operand.
4972+
Value *getPointerOperand() { return getOperand(0); }
4973+
/// Gets the pointer operand.
4974+
const Value *getPointerOperand() const { return getOperand(0); }
4975+
/// Gets the operand index of the pointer operand.
4976+
static unsigned getPointerOperandIndex() { return 0U; }
4977+
4978+
/// Returns the address space of the pointer operand.
4979+
unsigned getPointerAddressSpace() const {
4980+
return getPointerOperand()->getType()->getPointerAddressSpace();
4981+
}
4982+
4983+
// Methods for support type inquiry through isa, cast, and dyn_cast:
4984+
static bool classof(const Instruction *I) {
4985+
return I->getOpcode() == PtrToAddr;
4986+
}
4987+
static bool classof(const Value *V) {
4988+
return isa<Instruction>(V) && classof(cast<Instruction>(V));
4989+
}
4990+
};
4991+
49524992
//===----------------------------------------------------------------------===//
49534993
// BitCastInst Class
49544994
//===----------------------------------------------------------------------===//

llvm/include/llvm/SandboxIR/Instruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,7 @@ class CastInst : public UnaryInstruction {
22782278
return Opcode::FPToSI;
22792279
case llvm::Instruction::FPExt:
22802280
return Opcode::FPExt;
2281+
case llvm::Instruction::PtrToAddr:
22812282
case llvm::Instruction::PtrToInt:
22822283
return Opcode::PtrToInt;
22832284
case llvm::Instruction::IntToPtr:

llvm/include/llvm/Support/TargetOpcodes.def

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,9 @@ HANDLE_TARGET_OPCODE(G_CONCAT_VECTORS)
343343
/// Generic pointer to int conversion.
344344
HANDLE_TARGET_OPCODE(G_PTRTOINT)
345345

346+
/// Generic pointer to address conversion.
347+
HANDLE_TARGET_OPCODE(G_PTRTOADDR)
348+
346349
/// Generic int to pointer conversion.
347350
HANDLE_TARGET_OPCODE(G_INTTOPTR)
348351

llvm/include/llvm/Target/GenericOpcodes.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,12 @@ def G_PTRTOINT : GenericInstruction {
134134
let hasSideEffects = false;
135135
}
136136

137+
def G_PTRTOADDR : GenericInstruction {
138+
let OutOperandList = (outs type0:$dst);
139+
let InOperandList = (ins type1:$src);
140+
let hasSideEffects = false;
141+
}
142+
137143
def G_BITCAST : GenericInstruction {
138144
let OutOperandList = (outs type0:$dst);
139145
let InOperandList = (ins type1:$src);

llvm/include/llvm/Target/GlobalISel/Combine.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,8 @@ def unary_undef_to_zero: GICombineRule<
440440
def unary_undef_to_undef_frags : GICombinePatFrag<
441441
(outs root:$dst), (ins),
442442
!foreach(op,
443-
[G_TRUNC, G_BITCAST, G_ANYEXT, G_PTRTOINT, G_INTTOPTR, G_FPTOSI,
444-
G_FPTOUI],
443+
[G_TRUNC, G_BITCAST, G_ANYEXT, G_PTRTOINT, G_PTRTOADDR, G_INTTOPTR,
444+
G_FPTOSI, G_FPTOUI],
445445
(pattern (op $dst, $x), (G_IMPLICIT_DEF $x)))>;
446446
def unary_undef_to_undef : GICombineRule<
447447
(defs root:$dst),

llvm/include/llvm/Target/GlobalISel/SelectionDAGCompat.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ def : GINodeEquiv<G_TRUNC, trunc>;
5454
def : GINodeEquiv<G_BITCAST, bitconvert>;
5555
// G_INTTOPTR - SelectionDAG has no equivalent.
5656
// G_PTRTOINT - SelectionDAG has no equivalent.
57+
// G_PTRTOADDR - SelectionDAG has no equivalent.
5758
def : GINodeEquiv<G_CONSTANT, imm>;
5859
// timm must not be materialized and therefore has no GlobalISel equivalent
5960
def : GINodeEquiv<G_FCONSTANT, fpimm>;

llvm/lib/AsmParser/LLLexer.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,7 @@ lltok::Kind LLLexer::LexIdentifier() {
927927
INSTKEYWORD(fptoui, FPToUI);
928928
INSTKEYWORD(fptosi, FPToSI);
929929
INSTKEYWORD(inttoptr, IntToPtr);
930+
INSTKEYWORD(ptrtoaddr, PtrToAddr);
930931
INSTKEYWORD(ptrtoint, PtrToInt);
931932
INSTKEYWORD(bitcast, BitCast);
932933
INSTKEYWORD(addrspacecast, AddrSpaceCast);

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4274,6 +4274,7 @@ bool LLParser::parseValID(ValID &ID, PerFunctionState *PFS, Type *ExpectedTy) {
42744274
case lltok::kw_bitcast:
42754275
case lltok::kw_addrspacecast:
42764276
case lltok::kw_inttoptr:
4277+
// ptrtoaddr not supported in constant exprs (yet?).
42774278
case lltok::kw_ptrtoint: {
42784279
unsigned Opc = Lex.getUIntVal();
42794280
Type *DestTy = nullptr;
@@ -7236,6 +7237,7 @@ int LLParser::parseInstruction(Instruction *&Inst, BasicBlock *BB,
72367237
case lltok::kw_fptoui:
72377238
case lltok::kw_fptosi:
72387239
case lltok::kw_inttoptr:
7240+
case lltok::kw_ptrtoaddr:
72397241
case lltok::kw_ptrtoint:
72407242
return parseCast(Inst, PFS, KeywordVal);
72417243
case lltok::kw_fptrunc:

llvm/lib/Bitcode/Reader/BitcodeReader.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,6 +1275,7 @@ static int getDecodedCastOpcode(unsigned Val) {
12751275
case bitc::CAST_SITOFP : return Instruction::SIToFP;
12761276
case bitc::CAST_FPTRUNC : return Instruction::FPTrunc;
12771277
case bitc::CAST_FPEXT : return Instruction::FPExt;
1278+
case bitc::CAST_PTRTOADDR: return Instruction::PtrToAddr;
12781279
case bitc::CAST_PTRTOINT: return Instruction::PtrToInt;
12791280
case bitc::CAST_INTTOPTR: return Instruction::IntToPtr;
12801281
case bitc::CAST_BITCAST : return Instruction::BitCast;

llvm/lib/Bitcode/Writer/BitcodeWriter.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ static unsigned getEncodedCastOpcode(unsigned Opcode) {
641641
case Instruction::SIToFP : return bitc::CAST_SITOFP;
642642
case Instruction::FPTrunc : return bitc::CAST_FPTRUNC;
643643
case Instruction::FPExt : return bitc::CAST_FPEXT;
644+
case Instruction::PtrToAddr: return bitc::CAST_PTRTOADDR;
644645
case Instruction::PtrToInt: return bitc::CAST_PTRTOINT;
645646
case Instruction::IntToPtr: return bitc::CAST_INTTOPTR;
646647
case Instruction::BitCast : return bitc::CAST_BITCAST;

llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4814,7 +4814,8 @@ bool CombinerHelper::reassociationCanBreakAddressingModePattern(
48144814
MachineInstr *ConvUseMI = &UseMI;
48154815
unsigned ConvUseOpc = ConvUseMI->getOpcode();
48164816
while (ConvUseOpc == TargetOpcode::G_INTTOPTR ||
4817-
ConvUseOpc == TargetOpcode::G_PTRTOINT) {
4817+
ConvUseOpc == TargetOpcode::G_PTRTOINT ||
4818+
ConvUseOpc == TargetOpcode::G_PTRTOADDR) {
48184819
Register DefReg = ConvUseMI->getOperand(0).getReg();
48194820
if (!MRI.hasOneNonDBGUse(DefReg))
48204821
break;

llvm/lib/CodeGen/GlobalISel/GISelValueTracking.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -491,6 +491,7 @@ void GISelValueTracking::computeKnownBitsImpl(Register R, KnownBits &Known,
491491
}
492492
case TargetOpcode::G_INTTOPTR:
493493
case TargetOpcode::G_PTRTOINT:
494+
case TargetOpcode::G_PTRTOADDR:
494495
if (DstTy.isVector())
495496
break;
496497
// Fall through and handle them the same as zext/trunc.

0 commit comments

Comments
 (0)