mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-26 12:20:42 +00:00
Representation of 'atomic load' and 'atomic store' in IR.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137170 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -2567,6 +2567,28 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
InstructionList.push_back(I);
|
||||
break;
|
||||
}
|
||||
case bitc::FUNC_CODE_INST_LOADATOMIC: {
|
||||
// LOADATOMIC: [opty, op, align, vol, ordering, synchscope]
|
||||
unsigned OpNum = 0;
|
||||
Value *Op;
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
|
||||
OpNum+4 != Record.size())
|
||||
return Error("Invalid LOADATOMIC record");
|
||||
|
||||
|
||||
AtomicOrdering Ordering = GetDecodedOrdering(Record[OpNum+2]);
|
||||
if (Ordering == NotAtomic || Ordering == Release ||
|
||||
Ordering == AcquireRelease)
|
||||
return Error("Invalid LOADATOMIC record");
|
||||
if (Ordering != NotAtomic && Record[OpNum] == 0)
|
||||
return Error("Invalid LOADATOMIC record");
|
||||
SynchronizationScope SynchScope = GetDecodedSynchScope(Record[OpNum+3]);
|
||||
|
||||
I = new LoadInst(Op, "", Record[OpNum+1], (1 << Record[OpNum]) >> 1,
|
||||
Ordering, SynchScope);
|
||||
InstructionList.push_back(I);
|
||||
break;
|
||||
}
|
||||
case bitc::FUNC_CODE_INST_STORE: { // STORE2:[ptrty, ptr, val, align, vol]
|
||||
unsigned OpNum = 0;
|
||||
Value *Val, *Ptr;
|
||||
@@ -2580,6 +2602,29 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
InstructionList.push_back(I);
|
||||
break;
|
||||
}
|
||||
case bitc::FUNC_CODE_INST_STOREATOMIC: {
|
||||
// STOREATOMIC: [ptrty, ptr, val, align, vol, ordering, synchscope]
|
||||
unsigned OpNum = 0;
|
||||
Value *Val, *Ptr;
|
||||
if (getValueTypePair(Record, OpNum, NextValueNo, Ptr) ||
|
||||
getValue(Record, OpNum,
|
||||
cast<PointerType>(Ptr->getType())->getElementType(), Val) ||
|
||||
OpNum+4 != Record.size())
|
||||
return Error("Invalid STOREATOMIC record");
|
||||
|
||||
AtomicOrdering Ordering = GetDecodedOrdering(Record[OpNum+2]);
|
||||
if (Ordering == NotAtomic || Ordering == Release ||
|
||||
Ordering == AcquireRelease)
|
||||
return Error("Invalid STOREATOMIC record");
|
||||
SynchronizationScope SynchScope = GetDecodedSynchScope(Record[OpNum+3]);
|
||||
if (Ordering != NotAtomic && Record[OpNum] == 0)
|
||||
return Error("Invalid STOREATOMIC record");
|
||||
|
||||
I = new StoreInst(Val, Ptr, Record[OpNum+1], (1 << Record[OpNum]) >> 1,
|
||||
Ordering, SynchScope);
|
||||
InstructionList.push_back(I);
|
||||
break;
|
||||
}
|
||||
case bitc::FUNC_CODE_INST_CMPXCHG: {
|
||||
// CMPXCHG:[ptrty, ptr, cmp, new, vol, ordering, synchscope]
|
||||
unsigned OpNum = 0;
|
||||
@@ -2592,7 +2637,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
OpNum+3 != Record.size())
|
||||
return Error("Invalid CMPXCHG record");
|
||||
AtomicOrdering Ordering = GetDecodedOrdering(Record[OpNum+1]);
|
||||
if (Ordering == NotAtomic)
|
||||
if (Ordering == NotAtomic || Ordering == Unordered)
|
||||
return Error("Invalid CMPXCHG record");
|
||||
SynchronizationScope SynchScope = GetDecodedSynchScope(Record[OpNum+2]);
|
||||
I = new AtomicCmpXchgInst(Ptr, Cmp, New, Ordering, SynchScope);
|
||||
@@ -2614,7 +2659,7 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
|
||||
Operation > AtomicRMWInst::LAST_BINOP)
|
||||
return Error("Invalid ATOMICRMW record");
|
||||
AtomicOrdering Ordering = GetDecodedOrdering(Record[OpNum+2]);
|
||||
if (Ordering == NotAtomic)
|
||||
if (Ordering == NotAtomic || Ordering == Unordered)
|
||||
return Error("Invalid ATOMICRMW record");
|
||||
SynchronizationScope SynchScope = GetDecodedSynchScope(Record[OpNum+3]);
|
||||
I = new AtomicRMWInst(Operation, Ptr, Val, Ordering, SynchScope);
|
||||
|
||||
@@ -1175,19 +1175,34 @@ static void WriteInstruction(const Instruction &I, unsigned InstID,
|
||||
break;
|
||||
|
||||
case Instruction::Load:
|
||||
Code = bitc::FUNC_CODE_INST_LOAD;
|
||||
if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE)) // ptr
|
||||
AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
|
||||
|
||||
if (cast<LoadInst>(I).isAtomic()) {
|
||||
Code = bitc::FUNC_CODE_INST_LOADATOMIC;
|
||||
PushValueAndType(I.getOperand(0), InstID, Vals, VE);
|
||||
} else {
|
||||
Code = bitc::FUNC_CODE_INST_LOAD;
|
||||
if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE)) // ptr
|
||||
AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
|
||||
}
|
||||
Vals.push_back(Log2_32(cast<LoadInst>(I).getAlignment())+1);
|
||||
Vals.push_back(cast<LoadInst>(I).isVolatile());
|
||||
if (cast<LoadInst>(I).isAtomic()) {
|
||||
Vals.push_back(GetEncodedOrdering(cast<LoadInst>(I).getOrdering()));
|
||||
Vals.push_back(GetEncodedSynchScope(cast<LoadInst>(I).getSynchScope()));
|
||||
}
|
||||
break;
|
||||
case Instruction::Store:
|
||||
Code = bitc::FUNC_CODE_INST_STORE;
|
||||
if (cast<StoreInst>(I).isAtomic())
|
||||
Code = bitc::FUNC_CODE_INST_STOREATOMIC;
|
||||
else
|
||||
Code = bitc::FUNC_CODE_INST_STORE;
|
||||
PushValueAndType(I.getOperand(1), InstID, Vals, VE); // ptrty + ptr
|
||||
Vals.push_back(VE.getValueID(I.getOperand(0))); // val.
|
||||
Vals.push_back(Log2_32(cast<StoreInst>(I).getAlignment())+1);
|
||||
Vals.push_back(cast<StoreInst>(I).isVolatile());
|
||||
if (cast<StoreInst>(I).isAtomic()) {
|
||||
Vals.push_back(GetEncodedOrdering(cast<StoreInst>(I).getOrdering()));
|
||||
Vals.push_back(GetEncodedSynchScope(cast<StoreInst>(I).getSynchScope()));
|
||||
}
|
||||
break;
|
||||
case Instruction::AtomicCmpXchg:
|
||||
Code = bitc::FUNC_CODE_INST_CMPXCHG;
|
||||
|
||||
Reference in New Issue
Block a user