mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2026-04-27 04:18:42 +00:00
IR: add "cmpxchg weak" variant to support permitted failure.
This commit adds a weak variant of the cmpxchg operation, as described
in C++11. A cmpxchg instruction with this modifier is permitted to
fail to store, even if the comparison indicated it should.
As a result, cmpxchg instructions must return a flag indicating
success in addition to their original iN value loaded. Thus, for
uniformity *all* cmpxchg instructions now return "{ iN, i1 }". The
second flag is 1 when the store succeeded.
At the DAG level, a new ATOMIC_CMP_SWAP_WITH_SUCCESS node has been
added as the natural representation for the new cmpxchg instructions.
It is a strong cmpxchg.
By default this gets Expanded to the existing ATOMIC_CMP_SWAP during
Legalization, so existing backends should see no change in behaviour.
If they wish to deal with the enhanced node instead, they can call
setOperationAction on it. Beware: as a node with 2 results, it cannot
be selected from TableGen.
Currently, no use is made of the extra information provided in this
patch. Test updates are almost entirely adapting the input IR to the
new scheme.
Summary for out of tree users:
------------------------------
+ Legacy Bitcode files are upgraded during read.
+ Legacy assembly IR files will be invalid.
+ Front-ends must adapt to different type for "cmpxchg".
+ Backends should be unaffected by default.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210903 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
1 parent
1d5e37946d
commit
8f2a85e099
61 files changed
+628
-294
No files matched your search
@@ -490,7 +490,7 @@ lltok::Kind LLLexer::LexIdentifier() {
|
||||
KEYWORD(available_externally);
|
||||
KEYWORD(linkonce);
|
||||
KEYWORD(linkonce_odr);
|
||||
KEYWORD(weak);
|
||||
KEYWORD(weak); // Use as a linkage, and a modifier for "cmpxchg".
|
||||
KEYWORD(weak_odr);
|
||||
KEYWORD(appending);
|
||||
KEYWORD(dllimport);
|
||||
|
||||
@@ -4256,8 +4256,8 @@ int LLParser::ParseStore(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
}
|
||||
|
||||
/// ParseCmpXchg
|
||||
/// ::= 'cmpxchg' 'volatile'? TypeAndValue ',' TypeAndValue ',' TypeAndValue
|
||||
/// 'singlethread'? AtomicOrdering AtomicOrdering
|
||||
/// ::= 'cmpxchg' 'weak'? 'volatile'? TypeAndValue ',' TypeAndValue ','
|
||||
/// TypeAndValue 'singlethread'? AtomicOrdering AtomicOrdering
|
||||
int LLParser::ParseCmpXchg(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
Value *Ptr, *Cmp, *New; LocTy PtrLoc, CmpLoc, NewLoc;
|
||||
bool AteExtraComma = false;
|
||||
@@ -4265,6 +4265,10 @@ int LLParser::ParseCmpXchg(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
AtomicOrdering FailureOrdering = NotAtomic;
|
||||
SynchronizationScope Scope = CrossThread;
|
||||
bool isVolatile = false;
|
||||
bool isWeak = false;
|
||||
|
||||
if (EatIfPresent(lltok::kw_weak))
|
||||
isWeak = true;
|
||||
|
||||
if (EatIfPresent(lltok::kw_volatile))
|
||||
isVolatile = true;
|
||||
@@ -4297,9 +4301,10 @@ int LLParser::ParseCmpXchg(Instruction *&Inst, PerFunctionState &PFS) {
|
||||
return Error(NewLoc, "cmpxchg operand must be power-of-two byte-sized"
|
||||
" integer");
|
||||
|
||||
AtomicCmpXchgInst *CXI = new AtomicCmpXchgInst(Ptr, Cmp, New, SuccessOrdering,
|
||||
FailureOrdering, Scope);
|
||||
AtomicCmpXchgInst *CXI = new AtomicCmpXchgInst(
|
||||
Ptr, Cmp, New, SuccessOrdering, FailureOrdering, Scope);
|
||||
CXI->setVolatile(isVolatile);
|
||||
CXI->setWeak(isWeak);
|
||||
Inst = CXI;
|
||||
return AteExtraComma ? InstExtraComma : InstNormal;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace lltok {
|
||||
kw_linker_private, // NOTE: deprecated, for parser compatibility
|
||||
kw_linker_private_weak, // NOTE: deprecated, for parser compatibility
|
||||
kw_linkonce, kw_linkonce_odr,
|
||||
kw_weak, kw_weak_odr, kw_appending,
|
||||
kw_weak, // Used as a linkage, and a modifier for "cmpxchg".
|
||||
kw_weak_odr, kw_appending,
|
||||
kw_dllimport, kw_dllexport, kw_common, kw_available_externally,
|
||||
kw_default, kw_hidden, kw_protected,
|
||||
kw_unnamed_addr,
|
||||
|
||||
Reference in new issue
Block a user