@@ -129,6 +129,7 @@ class CastInst;
129
129
class PtrToIntInst ;
130
130
class BitCastInst ;
131
131
class AllocaInst ;
132
+ class AtomicCmpXchgInst ;
132
133
133
134
// / Iterator for the `Use` edges of a User's operands.
134
135
// / \Returns the operand `Use` when dereferenced.
@@ -246,6 +247,7 @@ class Value {
246
247
friend class InvokeInst ; // For getting `Val`.
247
248
friend class CallBrInst ; // For getting `Val`.
248
249
friend class GetElementPtrInst ; // For getting `Val`.
250
+ friend class AtomicCmpXchgInst ; // For getting `Val`.
249
251
friend class AllocaInst ; // For getting `Val`.
250
252
friend class CastInst ; // For getting `Val`.
251
253
friend class PHINode ; // For getting `Val`.
@@ -625,6 +627,7 @@ class Instruction : public sandboxir::User {
625
627
friend class InvokeInst ; // For getTopmostLLVMInstruction().
626
628
friend class CallBrInst ; // For getTopmostLLVMInstruction().
627
629
friend class GetElementPtrInst ; // For getTopmostLLVMInstruction().
630
+ friend class AtomicCmpXchgInst ; // For getTopmostLLVMInstruction().
628
631
friend class AllocaInst ; // For getTopmostLLVMInstruction().
629
632
friend class CastInst ; // For getTopmostLLVMInstruction().
630
633
friend class PHINode ; // For getTopmostLLVMInstruction().
@@ -1303,6 +1306,104 @@ class GetElementPtrInst final
1303
1306
// TODO: Add missing member functions.
1304
1307
};
1305
1308
1309
+ class AtomicCmpXchgInst
1310
+ : public SingleLLVMInstructionImpl<llvm::AtomicCmpXchgInst> {
1311
+ AtomicCmpXchgInst (llvm::AtomicCmpXchgInst *Atomic, Context &Ctx)
1312
+ : SingleLLVMInstructionImpl(ClassID::AtomicCmpXchg,
1313
+ Instruction::Opcode::AtomicCmpXchg, Atomic,
1314
+ Ctx) {}
1315
+ friend class Context ; // For constructor.
1316
+
1317
+ public:
1318
+ // / Return the alignment of the memory that is being allocated by the
1319
+ // / instruction.
1320
+ Align getAlign () const {
1321
+ return cast<llvm::AtomicCmpXchgInst>(Val)->getAlign ();
1322
+ }
1323
+
1324
+ void setAlignment (Align Align);
1325
+ // / Return true if this is a cmpxchg from a volatile memory
1326
+ // / location.
1327
+ bool isVolatile () const {
1328
+ return cast<llvm::AtomicCmpXchgInst>(Val)->isVolatile ();
1329
+ }
1330
+ // / Specify whether this is a volatile cmpxchg.
1331
+ void setVolatile (bool V);
1332
+ // / Return true if this cmpxchg may spuriously fail.
1333
+ bool isWeak () const { return cast<llvm::AtomicCmpXchgInst>(Val)->isWeak (); }
1334
+ void setWeak (bool IsWeak);
1335
+ static bool isValidSuccessOrdering (AtomicOrdering Ordering) {
1336
+ return llvm::AtomicCmpXchgInst::isValidSuccessOrdering (Ordering);
1337
+ }
1338
+ static bool isValidFailureOrdering (AtomicOrdering Ordering) {
1339
+ return llvm::AtomicCmpXchgInst::isValidFailureOrdering (Ordering);
1340
+ }
1341
+ AtomicOrdering getSuccessOrdering () const {
1342
+ return cast<llvm::AtomicCmpXchgInst>(Val)->getSuccessOrdering ();
1343
+ }
1344
+ void setSuccessOrdering (AtomicOrdering Ordering);
1345
+
1346
+ AtomicOrdering getFailureOrdering () const {
1347
+ return cast<llvm::AtomicCmpXchgInst>(Val)->getFailureOrdering ();
1348
+ }
1349
+ void setFailureOrdering (AtomicOrdering Ordering);
1350
+ AtomicOrdering getMergedOrdering () const {
1351
+ return cast<llvm::AtomicCmpXchgInst>(Val)->getMergedOrdering ();
1352
+ }
1353
+ SyncScope::ID getSyncScopeID () const {
1354
+ return cast<llvm::AtomicCmpXchgInst>(Val)->getSyncScopeID ();
1355
+ }
1356
+ void setSyncScopeID (SyncScope::ID SSID);
1357
+ Value *getPointerOperand ();
1358
+ const Value *getPointerOperand () const {
1359
+ return const_cast <AtomicCmpXchgInst *>(this )->getPointerOperand ();
1360
+ }
1361
+
1362
+ Value *getCompareOperand ();
1363
+ const Value *getCompareOperand () const {
1364
+ return const_cast <AtomicCmpXchgInst *>(this )->getCompareOperand ();
1365
+ }
1366
+
1367
+ Value *getNewValOperand ();
1368
+ const Value *getNewValOperand () const {
1369
+ return const_cast <AtomicCmpXchgInst *>(this )->getNewValOperand ();
1370
+ }
1371
+
1372
+ // / Returns the address space of the pointer operand.
1373
+ unsigned getPointerAddressSpace () const {
1374
+ return cast<llvm::AtomicCmpXchgInst>(Val)->getPointerAddressSpace ();
1375
+ }
1376
+
1377
+ // / Returns the strongest permitted ordering on failure, given the
1378
+ // / desired ordering on success.
1379
+ // /
1380
+ // / If the comparison in a cmpxchg operation fails, there is no atomic store
1381
+ // / so release semantics cannot be provided. So this function drops explicit
1382
+ // / Release requests from the AtomicOrdering. A SequentiallyConsistent
1383
+ // / operation would remain SequentiallyConsistent.
1384
+ static AtomicOrdering
1385
+ getStrongestFailureOrdering (AtomicOrdering SuccessOrdering) {
1386
+ return llvm::AtomicCmpXchgInst::getStrongestFailureOrdering (
1387
+ SuccessOrdering);
1388
+ }
1389
+
1390
+ static AtomicCmpXchgInst *
1391
+ create (Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align,
1392
+ AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
1393
+ BBIterator WhereIt, BasicBlock *WhereBB, Context &Ctx,
1394
+ SyncScope::ID SSID = SyncScope::System, const Twine &Name = " " );
1395
+ static AtomicCmpXchgInst *
1396
+ create (Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align,
1397
+ AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
1398
+ Instruction *InsertBefore, Context &Ctx,
1399
+ SyncScope::ID SSID = SyncScope::System, const Twine &Name = " " );
1400
+ static AtomicCmpXchgInst *
1401
+ create (Value *Ptr, Value *Cmp, Value *New, MaybeAlign Align,
1402
+ AtomicOrdering SuccessOrdering, AtomicOrdering FailureOrdering,
1403
+ BasicBlock *InsertAtEnd, Context &Ctx,
1404
+ SyncScope::ID SSID = SyncScope::System, const Twine &Name = " " );
1405
+ };
1406
+
1306
1407
class AllocaInst final : public UnaryInstruction {
1307
1408
AllocaInst (llvm::AllocaInst *AI, Context &Ctx)
1308
1409
: UnaryInstruction(ClassID::Alloca, Instruction::Opcode::Alloca, AI,
@@ -1660,6 +1761,8 @@ class Context {
1660
1761
friend CallBrInst; // For createCallBrInst()
1661
1762
GetElementPtrInst *createGetElementPtrInst (llvm::GetElementPtrInst *I);
1662
1763
friend GetElementPtrInst; // For createGetElementPtrInst()
1764
+ AtomicCmpXchgInst *createAtomicCmpXchgInst (llvm::AtomicCmpXchgInst *I);
1765
+ friend AtomicCmpXchgInst; // For createAtomicCmpXchgInst()
1663
1766
AllocaInst *createAllocaInst (llvm::AllocaInst *I);
1664
1767
friend AllocaInst; // For createAllocaInst()
1665
1768
CastInst *createCastInst (llvm::CastInst *I);
0 commit comments