@@ -111,6 +111,7 @@ class Context;
111
111
class Function ;
112
112
class Instruction ;
113
113
class SelectInst ;
114
+ class ExtractElementInst ;
114
115
class InsertElementInst ;
115
116
class BranchInst ;
116
117
class UnaryInstruction ;
@@ -232,24 +233,25 @@ class Value {
232
233
// / order.
233
234
llvm::Value *Val = nullptr ;
234
235
235
- friend class Context ; // For getting `Val`.
236
- friend class User ; // For getting `Val`.
237
- friend class Use ; // For getting `Val`.
238
- friend class SelectInst ; // For getting `Val`.
239
- friend class InsertElementInst ; // For getting `Val`.
240
- friend class BranchInst ; // For getting `Val`.
241
- friend class LoadInst ; // For getting `Val`.
242
- friend class StoreInst ; // For getting `Val`.
243
- friend class ReturnInst ; // For getting `Val`.
244
- friend class CallBase ; // For getting `Val`.
245
- friend class CallInst ; // For getting `Val`.
246
- friend class InvokeInst ; // For getting `Val`.
247
- friend class CallBrInst ; // For getting `Val`.
248
- friend class GetElementPtrInst ; // For getting `Val`.
249
- friend class AllocaInst ; // For getting `Val`.
250
- friend class CastInst ; // For getting `Val`.
251
- friend class PHINode ; // For getting `Val`.
252
- friend class UnreachableInst ; // For getting `Val`.
236
+ friend class Context ; // For getting `Val`.
237
+ friend class User ; // For getting `Val`.
238
+ friend class Use ; // For getting `Val`.
239
+ friend class SelectInst ; // For getting `Val`.
240
+ friend class ExtractElementInst ; // For getting `Val`.
241
+ friend class InsertElementInst ; // For getting `Val`.
242
+ friend class BranchInst ; // For getting `Val`.
243
+ friend class LoadInst ; // For getting `Val`.
244
+ friend class StoreInst ; // For getting `Val`.
245
+ friend class ReturnInst ; // For getting `Val`.
246
+ friend class CallBase ; // For getting `Val`.
247
+ friend class CallInst ; // For getting `Val`.
248
+ friend class InvokeInst ; // For getting `Val`.
249
+ friend class CallBrInst ; // For getting `Val`.
250
+ friend class GetElementPtrInst ; // For getting `Val`.
251
+ friend class AllocaInst ; // For getting `Val`.
252
+ friend class CastInst ; // For getting `Val`.
253
+ friend class PHINode ; // For getting `Val`.
254
+ friend class UnreachableInst ; // For getting `Val`.
253
255
254
256
// / All values point to the context.
255
257
Context &Ctx;
@@ -615,20 +617,21 @@ class Instruction : public sandboxir::User {
615
617
// / A SandboxIR Instruction may map to multiple LLVM IR Instruction. This
616
618
// / returns its topmost LLVM IR instruction.
617
619
llvm::Instruction *getTopmostLLVMInstruction () const ;
618
- friend class SelectInst ; // For getTopmostLLVMInstruction().
619
- friend class InsertElementInst ; // For getTopmostLLVMInstruction().
620
- friend class BranchInst ; // For getTopmostLLVMInstruction().
621
- friend class LoadInst ; // For getTopmostLLVMInstruction().
622
- friend class StoreInst ; // For getTopmostLLVMInstruction().
623
- friend class ReturnInst ; // For getTopmostLLVMInstruction().
624
- friend class CallInst ; // For getTopmostLLVMInstruction().
625
- friend class InvokeInst ; // For getTopmostLLVMInstruction().
626
- friend class CallBrInst ; // For getTopmostLLVMInstruction().
627
- friend class GetElementPtrInst ; // For getTopmostLLVMInstruction().
628
- friend class AllocaInst ; // For getTopmostLLVMInstruction().
629
- friend class CastInst ; // For getTopmostLLVMInstruction().
630
- friend class PHINode ; // For getTopmostLLVMInstruction().
631
- friend class UnreachableInst ; // For getTopmostLLVMInstruction().
620
+ friend class SelectInst ; // For getTopmostLLVMInstruction().
621
+ friend class ExtractElementInst ; // For getTopmostLLVMInstruction().
622
+ friend class InsertElementInst ; // For getTopmostLLVMInstruction().
623
+ friend class BranchInst ; // For getTopmostLLVMInstruction().
624
+ friend class LoadInst ; // For getTopmostLLVMInstruction().
625
+ friend class StoreInst ; // For getTopmostLLVMInstruction().
626
+ friend class ReturnInst ; // For getTopmostLLVMInstruction().
627
+ friend class CallInst ; // For getTopmostLLVMInstruction().
628
+ friend class InvokeInst ; // For getTopmostLLVMInstruction().
629
+ friend class CallBrInst ; // For getTopmostLLVMInstruction().
630
+ friend class GetElementPtrInst ; // For getTopmostLLVMInstruction().
631
+ friend class AllocaInst ; // For getTopmostLLVMInstruction().
632
+ friend class CastInst ; // For getTopmostLLVMInstruction().
633
+ friend class PHINode ; // For getTopmostLLVMInstruction().
634
+ friend class UnreachableInst ; // For getTopmostLLVMInstruction().
632
635
633
636
// / \Returns the LLVM IR Instructions that this SandboxIR maps to in program
634
637
// / order.
@@ -768,6 +771,37 @@ class InsertElementInst final
768
771
}
769
772
};
770
773
774
+ class ExtractElementInst final
775
+ : public SingleLLVMInstructionImpl<llvm::ExtractElementInst> {
776
+ // / Use Context::createExtractElementInst() instead.
777
+ ExtractElementInst (llvm::Instruction *I, Context &Ctx)
778
+ : SingleLLVMInstructionImpl(ClassID::ExtractElement,
779
+ Opcode::ExtractElement, I, Ctx) {}
780
+ friend class Context ; // For accessing the constructor in
781
+ // create*()
782
+
783
+ public:
784
+ static Value *create (Value *Vec, Value *Idx, Instruction *InsertBefore,
785
+ Context &Ctx, const Twine &Name = " " );
786
+ static Value *create (Value *Vec, Value *Idx, BasicBlock *InsertAtEnd,
787
+ Context &Ctx, const Twine &Name = " " );
788
+ static bool classof (const Value *From) {
789
+ return From->getSubclassID () == ClassID::ExtractElement;
790
+ }
791
+
792
+ static bool isValidOperands (const Value *Vec, const Value *Idx) {
793
+ return llvm::ExtractElementInst::isValidOperands (Vec->Val , Idx->Val );
794
+ }
795
+ Value *getVectorOperand () { return getOperand (0 ); }
796
+ Value *getIndexOperand () { return getOperand (1 ); }
797
+ const Value *getVectorOperand () const { return getOperand (0 ); }
798
+ const Value *getIndexOperand () const { return getOperand (1 ); }
799
+
800
+ VectorType *getVectorOperandType () const {
801
+ return cast<VectorType>(getVectorOperand ()->getType ());
802
+ }
803
+ };
804
+
771
805
class BranchInst : public SingleLLVMInstructionImpl <llvm::BranchInst> {
772
806
// / Use Context::createBranchInst(). Don't call the constructor directly.
773
807
BranchInst (llvm::BranchInst *BI, Context &Ctx)
@@ -1644,6 +1678,8 @@ class Context {
1644
1678
friend SelectInst; // For createSelectInst()
1645
1679
InsertElementInst *createInsertElementInst (llvm::InsertElementInst *IEI);
1646
1680
friend InsertElementInst; // For createInsertElementInst()
1681
+ ExtractElementInst *createExtractElementInst (llvm::ExtractElementInst *EEI);
1682
+ friend ExtractElementInst; // For createExtractElementInst()
1647
1683
BranchInst *createBranchInst (llvm::BranchInst *I);
1648
1684
friend BranchInst; // For createBranchInst()
1649
1685
LoadInst *createLoadInst (llvm::LoadInst *LI);
0 commit comments