@@ -111,6 +111,7 @@ class ConstantInt;
111111class Context ;
112112class Function ;
113113class Instruction ;
114+ class FenceInst ;
114115class SelectInst ;
115116class ExtractElementInst ;
116117class InsertElementInst ;
@@ -249,6 +250,7 @@ class Value {
249250 friend class Context ; // For getting `Val`.
250251 friend class User ; // For getting `Val`.
251252 friend class Use ; // For getting `Val`.
253+ friend class FenceInst ; // For getting `Val`.
252254 friend class SelectInst ; // For getting `Val`.
253255 friend class ExtractElementInst ; // For getting `Val`.
254256 friend class InsertElementInst ; // For getting `Val`.
@@ -678,6 +680,7 @@ class Instruction : public sandboxir::User {
678680 // / A SandboxIR Instruction may map to multiple LLVM IR Instruction. This
679681 // / returns its topmost LLVM IR instruction.
680682 llvm::Instruction *getTopmostLLVMInstruction () const ;
683+ friend class FenceInst ; // For getTopmostLLVMInstruction().
681684 friend class SelectInst ; // For getTopmostLLVMInstruction().
682685 friend class ExtractElementInst ; // For getTopmostLLVMInstruction().
683686 friend class InsertElementInst ; // For getTopmostLLVMInstruction().
@@ -882,6 +885,33 @@ template <typename LLVMT> class SingleLLVMInstructionImpl : public Instruction {
882885#endif
883886};
884887
888+ class FenceInst : public SingleLLVMInstructionImpl <llvm::SelectInst> {
889+ FenceInst (llvm::FenceInst *FI, Context &Ctx)
890+ : SingleLLVMInstructionImpl(ClassID::Fence, Opcode::Fence, FI, Ctx) {}
891+ friend Context; // For constructor;
892+
893+ public:
894+ static FenceInst *create (AtomicOrdering Ordering, BBIterator WhereIt,
895+ BasicBlock *WhereBB, Context &Ctx,
896+ SyncScope::ID SSID = SyncScope::System);
897+ // / Returns the ordering constraint of this fence instruction.
898+ AtomicOrdering getOrdering () const {
899+ return cast<llvm::FenceInst>(Val)->getOrdering ();
900+ }
901+ // / Sets the ordering constraint of this fence instruction. May only be
902+ // / Acquire, Release, AcquireRelease, or SequentiallyConsistent.
903+ void setOrdering (AtomicOrdering Ordering);
904+ // / Returns the synchronization scope ID of this fence instruction.
905+ SyncScope::ID getSyncScopeID () const {
906+ return cast<llvm::FenceInst>(Val)->getSyncScopeID ();
907+ }
908+ // / Sets the synchronization scope ID of this fence instruction.
909+ void setSyncScopeID (SyncScope::ID SSID);
910+ static bool classof (const Value *From) {
911+ return From->getSubclassID () == ClassID::Fence;
912+ }
913+ };
914+
885915class SelectInst : public SingleLLVMInstructionImpl <llvm::SelectInst> {
886916 // / Use Context::createSelectInst(). Don't call the
887917 // / constructor directly.
@@ -2854,6 +2884,8 @@ class Context {
28542884 IRBuilder<ConstantFolder> LLVMIRBuilder;
28552885 auto &getLLVMIRBuilder () { return LLVMIRBuilder; }
28562886
2887+ FenceInst *createFenceInst (llvm::FenceInst *SI);
2888+ friend FenceInst; // For createFenceInst()
28572889 SelectInst *createSelectInst (llvm::SelectInst *SI);
28582890 friend SelectInst; // For createSelectInst()
28592891 InsertElementInst *createInsertElementInst (llvm::InsertElementInst *IEI);
0 commit comments