mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 16:33:28 +00:00
Fix atomic load and store on x86 to pass -verify-machineinstrs (and possibly fix some subtle bugs involving passes which check mayStore()).
This isn't exactly ideal, but it is good enough for the moment. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139245 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
90502888f2
commit
d5ccb0558f
@ -741,6 +741,32 @@ def LXADD64 : RI<0xC1, MRMSrcMem, (outs GR64:$dst), (ins GR64:$val,i64mem:$ptr),
|
||||
TB, LOCK;
|
||||
}
|
||||
|
||||
def ACQUIRE_MOV8rm : I<0, Pseudo, (outs GR8 :$dst), (ins i8mem :$src),
|
||||
"#ACQUIRE_MOV PSEUDO!",
|
||||
[(set GR8:$dst, (atomic_load_8 addr:$src))]>;
|
||||
def ACQUIRE_MOV16rm : I<0, Pseudo, (outs GR16:$dst), (ins i16mem:$src),
|
||||
"#ACQUIRE_MOV PSEUDO!",
|
||||
[(set GR16:$dst, (atomic_load_16 addr:$src))]>;
|
||||
def ACQUIRE_MOV32rm : I<0, Pseudo, (outs GR32:$dst), (ins i32mem:$src),
|
||||
"#ACQUIRE_MOV PSEUDO!",
|
||||
[(set GR32:$dst, (atomic_load_32 addr:$src))]>;
|
||||
def ACQUIRE_MOV64rm : I<0, Pseudo, (outs GR64:$dst), (ins i64mem:$src),
|
||||
"#ACQUIRE_MOV PSEUDO!",
|
||||
[(set GR64:$dst, (atomic_load_64 addr:$src))]>;
|
||||
|
||||
def RELEASE_MOV8mr : I<0, Pseudo, (outs), (ins i8mem :$dst, GR8 :$src),
|
||||
"#RELEASE_MOV PSEUDO!",
|
||||
[(atomic_store_8 addr:$dst, GR8 :$src)]>;
|
||||
def RELEASE_MOV16mr : I<0, Pseudo, (outs), (ins i16mem:$dst, GR16:$src),
|
||||
"#RELEASE_MOV PSEUDO!",
|
||||
[(atomic_store_16 addr:$dst, GR16:$src)]>;
|
||||
def RELEASE_MOV32mr : I<0, Pseudo, (outs), (ins i32mem:$dst, GR32:$src),
|
||||
"#RELEASE_MOV PSEUDO!",
|
||||
[(atomic_store_32 addr:$dst, GR32:$src)]>;
|
||||
def RELEASE_MOV64mr : I<0, Pseudo, (outs), (ins i64mem:$dst, GR64:$src),
|
||||
"#RELEASE_MOV PSEUDO!",
|
||||
[(atomic_store_64 addr:$dst, GR64:$src)]>;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Conditional Move Pseudo Instructions.
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -1709,17 +1735,3 @@ def : Pat<(and GR64:$src1, i64immSExt8:$src2),
|
||||
(AND64ri8 GR64:$src1, i64immSExt8:$src2)>;
|
||||
def : Pat<(and GR64:$src1, i64immSExt32:$src2),
|
||||
(AND64ri32 GR64:$src1, i64immSExt32:$src2)>;
|
||||
|
||||
def : Pat<(atomic_load_8 addr:$src), (MOV8rm addr:$src)>;
|
||||
def : Pat<(atomic_load_16 addr:$src), (MOV16rm addr:$src)>;
|
||||
def : Pat<(atomic_load_32 addr:$src), (MOV32rm addr:$src)>;
|
||||
def : Pat<(atomic_load_64 addr:$src), (MOV64rm addr:$src)>;
|
||||
|
||||
def : Pat<(atomic_store_8 addr:$ptr, GR8:$val),
|
||||
(MOV8mr addr:$ptr, GR8:$val)>;
|
||||
def : Pat<(atomic_store_16 addr:$ptr, GR16:$val),
|
||||
(MOV16mr addr:$ptr, GR16:$val)>;
|
||||
def : Pat<(atomic_store_32 addr:$ptr, GR32:$val),
|
||||
(MOV32mr addr:$ptr, GR32:$val)>;
|
||||
def : Pat<(atomic_store_64 addr:$ptr, GR64:$val),
|
||||
(MOV64mr addr:$ptr, GR64:$val)>;
|
||||
|
@ -469,6 +469,18 @@ ReSimplify:
|
||||
case X86::JLE_4: OutMI.setOpcode(X86::JLE_1); break;
|
||||
case X86::JG_4: OutMI.setOpcode(X86::JG_1); break;
|
||||
|
||||
// Atomic load and store require a separate pseudo-inst because Acquire
|
||||
// implies mayStore and Release implies mayLoad; fix these to regular MOV
|
||||
// instructions here
|
||||
case X86::ACQUIRE_MOV8rm: OutMI.setOpcode(X86::MOV8rm); goto ReSimplify;
|
||||
case X86::ACQUIRE_MOV16rm: OutMI.setOpcode(X86::MOV16rm); goto ReSimplify;
|
||||
case X86::ACQUIRE_MOV32rm: OutMI.setOpcode(X86::MOV32rm); goto ReSimplify;
|
||||
case X86::ACQUIRE_MOV64rm: OutMI.setOpcode(X86::MOV64rm); goto ReSimplify;
|
||||
case X86::RELEASE_MOV8mr: OutMI.setOpcode(X86::MOV8mr); goto ReSimplify;
|
||||
case X86::RELEASE_MOV16mr: OutMI.setOpcode(X86::MOV16mr); goto ReSimplify;
|
||||
case X86::RELEASE_MOV32mr: OutMI.setOpcode(X86::MOV32mr); goto ReSimplify;
|
||||
case X86::RELEASE_MOV64mr: OutMI.setOpcode(X86::MOV64mr); goto ReSimplify;
|
||||
|
||||
// We don't currently select the correct instruction form for instructions
|
||||
// which have a short %eax, etc. form. Handle this by custom lowering, for
|
||||
// now.
|
||||
|
@ -1,4 +1,4 @@
|
||||
; RUN: llc < %s -mtriple=x86_64-apple-macosx10.7.0 | FileCheck %s
|
||||
; RUN: llc < %s -mtriple=x86_64-apple-macosx10.7.0 -verify-machineinstrs | FileCheck %s
|
||||
; RUN: llc < %s -mtriple=x86_64-apple-macosx10.7.0 -O0 | FileCheck %s
|
||||
|
||||
define void @test1(i32* %ptr, i32 %val1) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user