mirror of
https://github.com/RPCSX/llvm.git
synced 2025-02-03 11:08:32 +00:00
MIR Serialization: Use the global value syntax for global value memory operands.
This commit modifies the serialization syntax so that the global IR values in machine memory operands use the global value '@<name>' syntax instead of the current '%ir.<name>' syntax. The unnamed global IR values are handled by this commit as well, as the existing global value parsing method can parse the unnamed globals already. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@245527 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
77676424fd
commit
e2e6dea9f2
@ -1531,9 +1531,6 @@ bool MIParser::parseIRValue(const Value *&V) {
|
||||
switch (Token.kind()) {
|
||||
case MIToken::NamedIRValue: {
|
||||
V = MF.getFunction()->getValueSymbolTable().lookup(Token.stringValue());
|
||||
if (!V)
|
||||
V = MF.getFunction()->getParent()->getValueSymbolTable().lookup(
|
||||
Token.stringValue());
|
||||
break;
|
||||
}
|
||||
case MIToken::IRValue: {
|
||||
@ -1543,6 +1540,14 @@ bool MIParser::parseIRValue(const Value *&V) {
|
||||
V = getIRValue(SlotNumber);
|
||||
break;
|
||||
}
|
||||
case MIToken::NamedGlobalValue:
|
||||
case MIToken::GlobalValue: {
|
||||
GlobalValue *GV = nullptr;
|
||||
if (parseGlobalValue(GV))
|
||||
return true;
|
||||
V = GV;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
llvm_unreachable("The current token should be an IR block reference");
|
||||
}
|
||||
@ -1646,7 +1651,9 @@ bool MIParser::parseMachinePointerInfo(MachinePointerInfo &Dest) {
|
||||
Dest = MachinePointerInfo(PSV, Offset);
|
||||
return false;
|
||||
}
|
||||
if (Token.isNot(MIToken::NamedIRValue) && Token.isNot(MIToken::IRValue))
|
||||
if (Token.isNot(MIToken::NamedIRValue) && Token.isNot(MIToken::IRValue) &&
|
||||
Token.isNot(MIToken::GlobalValue) &&
|
||||
Token.isNot(MIToken::NamedGlobalValue))
|
||||
return error("expected an IR value reference");
|
||||
const Value *V = nullptr;
|
||||
if (parseIRValue(V))
|
||||
|
@ -608,7 +608,10 @@ void MIPrinter::printIRBlockReference(const BasicBlock &BB) {
|
||||
}
|
||||
|
||||
void MIPrinter::printIRValueReference(const Value &V) {
|
||||
// TODO: Global values should use the '@' syntax.
|
||||
if (isa<GlobalValue>(V)) {
|
||||
V.printAsOperand(OS, /*PrintType=*/false, MST);
|
||||
return;
|
||||
}
|
||||
OS << "%ir.";
|
||||
if (V.hasName()) {
|
||||
printLLVMNameWithoutPrefix(OS, V.getName());
|
||||
|
@ -32,10 +32,10 @@ stack:
|
||||
body: |
|
||||
bb.0.entry:
|
||||
%0 = ADRP @var
|
||||
%1 = LDRXui killed %0, @var :: (load 8 from %ir.var)
|
||||
%1 = LDRXui killed %0, @var :: (load 8 from @var)
|
||||
STRXui killed %1, %stack.0.local_var, 0 :: (store 8 into %ir.local_var)
|
||||
%2 = ADRP @local_addr
|
||||
%3 = ADDXri %stack.0.local_var, 0, 0
|
||||
STRXui killed %3, killed %2, @local_addr :: (store 8 into %ir.local_addr)
|
||||
STRXui killed %3, killed %2, @local_addr :: (store 8 into @local_addr)
|
||||
RET_ReallyLR
|
||||
...
|
||||
|
@ -57,7 +57,7 @@ body: |
|
||||
|
||||
frame-setup PUSH64r killed %rbx, implicit-def %rsp, implicit %rsp
|
||||
%rsp = frame-setup SUB64ri8 %rsp, 32, implicit-def dead %eflags
|
||||
%rbx = LOAD_STACK_GUARD :: (invariant load 8 from %ir.__stack_chk_guard)
|
||||
%rbx = LOAD_STACK_GUARD :: (invariant load 8 from @__stack_chk_guard)
|
||||
MOV64mr %rsp, 1, _, 24, _, %rbx
|
||||
%rsi = LEA64r %rsp, 1, _, 19, _
|
||||
MOV64mr %rsp, 1, _, 8, _, %rsi
|
||||
|
@ -93,11 +93,15 @@
|
||||
ret i32 %b
|
||||
}
|
||||
|
||||
@0 = external global i32
|
||||
|
||||
define i32 @global_value() {
|
||||
entry:
|
||||
%a = load i32, i32* @G
|
||||
%b = add i32 %a, 1
|
||||
ret i32 %b
|
||||
%c = load i32, i32* @0
|
||||
%d = add i32 %b, %c
|
||||
ret i32 %d
|
||||
}
|
||||
|
||||
define i32 @jumptable_psv(i32 %in) {
|
||||
@ -358,10 +362,13 @@ tracksRegLiveness: true
|
||||
body: |
|
||||
bb.0.entry:
|
||||
%rax = MOV64rm %rip, 1, _, @G, _
|
||||
; CHECK: name: global_value
|
||||
; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.G)
|
||||
%eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.G)
|
||||
%eax = INC32r killed %eax, implicit-def dead %eflags
|
||||
; CHECK-LABEL: name: global_value
|
||||
; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @G)
|
||||
; CHECK: %ecx = MOV32rm killed %rcx, 1, _, 0, _, implicit-def %rcx :: (load 4 from @0)
|
||||
%eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @G)
|
||||
%rcx = MOV64rm %rip, 1, _, @0, _
|
||||
%ecx = MOV32rm killed %rcx, 1, _, 0, _, implicit-def %rcx :: (load 4 from @0)
|
||||
%eax = LEA64_32r killed %rax, 1, killed %rcx, 1, _
|
||||
RETQ %eax
|
||||
...
|
||||
---
|
||||
@ -421,9 +428,9 @@ body: |
|
||||
bb.0.entry:
|
||||
%rax = MOV64rm %rip, 1, _, @a, _ :: (load 8 from got)
|
||||
; CHECK-LABEL: name: tbaa_metadata
|
||||
; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.a, !tbaa !2)
|
||||
; CHECK: %eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @a, !tbaa !2)
|
||||
; CHECK-NEXT: %eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.total_len2, !tbaa !6)
|
||||
%eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from %ir.a, !tbaa !2)
|
||||
%eax = MOV32rm killed %rax, 1, _, 0, _, implicit-def %rax :: (load 4 from @a, !tbaa !2)
|
||||
%eax = MOV32rm killed %rax, 1, _, 0, _ :: (load 4 from %ir.total_len2, !tbaa !6)
|
||||
RETQ %eax
|
||||
...
|
||||
|
Loading…
x
Reference in New Issue
Block a user