forked from OSchip/llvm-project
MIR Serialization: Change syntax for the call entry pseudo source values.
The global IR values in machine memory operands should use the global value '@<name>' syntax instead of the current '%ir.<name>' syntax. However, the global value call entry pseudo source values use the global value syntax already. Therefore, the syntax for the call entry pseudo source values has to be changed so that the global values and call entry global value PSVs can be parsed without ambiguities. llvm-svn: 245526
This commit is contained in:
parent
7defcae5f7
commit
0d009645a1
|
@ -220,6 +220,7 @@ static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {
|
|||
.Case("got", MIToken::kw_got)
|
||||
.Case("jump-table", MIToken::kw_jump_table)
|
||||
.Case("constant-pool", MIToken::kw_constant_pool)
|
||||
.Case("call-entry", MIToken::kw_call_entry)
|
||||
.Case("liveout", MIToken::kw_liveout)
|
||||
.Case("address-taken", MIToken::kw_address_taken)
|
||||
.Case("landing-pad", MIToken::kw_landing_pad)
|
||||
|
|
|
@ -81,6 +81,7 @@ struct MIToken {
|
|||
kw_got,
|
||||
kw_jump_table,
|
||||
kw_constant_pool,
|
||||
kw_call_entry,
|
||||
kw_liveout,
|
||||
kw_address_taken,
|
||||
kw_landing_pad,
|
||||
|
|
|
@ -1605,18 +1605,27 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) {
|
|||
// The token was already consumed, so use return here instead of break.
|
||||
return false;
|
||||
}
|
||||
case MIToken::GlobalValue:
|
||||
case MIToken::NamedGlobalValue: {
|
||||
GlobalValue *GV = nullptr;
|
||||
if (parseGlobalValue(GV))
|
||||
return true;
|
||||
PSV = MF.getPSVManager().getGlobalValueCallEntry(GV);
|
||||
case MIToken::kw_call_entry: {
|
||||
lex();
|
||||
switch (Token.kind()) {
|
||||
case MIToken::GlobalValue:
|
||||
case MIToken::NamedGlobalValue: {
|
||||
GlobalValue *GV = nullptr;
|
||||
if (parseGlobalValue(GV))
|
||||
return true;
|
||||
PSV = MF.getPSVManager().getGlobalValueCallEntry(GV);
|
||||
break;
|
||||
}
|
||||
case MIToken::ExternalSymbol:
|
||||
PSV = MF.getPSVManager().getExternalSymbolCallEntry(
|
||||
MF.createExternalSymbolName(Token.stringValue()));
|
||||
break;
|
||||
default:
|
||||
return error(
|
||||
"expected a global value or an external symbol after 'call-entry'");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case MIToken::ExternalSymbol:
|
||||
PSV = MF.getPSVManager().getExternalSymbolCallEntry(
|
||||
MF.createExternalSymbolName(Token.stringValue()));
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("The current token should be pseudo source value");
|
||||
}
|
||||
|
@ -1627,9 +1636,7 @@ bool MIParser::parseMemoryPseudoSourceValue(const PseudoSourceValue *&PSV) {
|
|||
bool MIParser::parseMachinePointerInfo(MachinePointerInfo &Dest) {
|
||||
if (Token.is(MIToken::kw_constant_pool) || Token.is(MIToken::kw_stack) ||
|
||||
Token.is(MIToken::kw_got) || Token.is(MIToken::kw_jump_table) ||
|
||||
Token.is(MIToken::FixedStackObject) || Token.is(MIToken::GlobalValue) ||
|
||||
Token.is(MIToken::NamedGlobalValue) ||
|
||||
Token.is(MIToken::ExternalSymbol)) {
|
||||
Token.is(MIToken::FixedStackObject) || Token.is(MIToken::kw_call_entry)) {
|
||||
const PseudoSourceValue *PSV = nullptr;
|
||||
if (parseMemoryPseudoSourceValue(PSV))
|
||||
return true;
|
||||
|
|
|
@ -873,11 +873,12 @@ void MIPrinter::print(const MachineMemOperand &Op) {
|
|||
cast<FixedStackPseudoSourceValue>(PVal)->getFrameIndex());
|
||||
break;
|
||||
case PseudoSourceValue::GlobalValueCallEntry:
|
||||
OS << "call-entry ";
|
||||
cast<GlobalValuePseudoSourceValue>(PVal)->getValue()->printAsOperand(
|
||||
OS, /*PrintType=*/false, MST);
|
||||
break;
|
||||
case PseudoSourceValue::ExternalSymbolCallEntry:
|
||||
OS << '$';
|
||||
OS << "call-entry $";
|
||||
printLLVMNameWithoutPrefix(
|
||||
OS, cast<ExternalSymbolPseudoSourceValue>(PVal)->getSymbol());
|
||||
break;
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
# RUN: not llc -march=mipsel -mcpu=mips16 -relocation-model=pic -start-after branch-folder -stop-after branch-folder -o /dev/null %s 2>&1 | FileCheck %s
|
||||
--- |
|
||||
define i32 @test(i32 %a) {
|
||||
entry:
|
||||
%call = call i32 @foo(i32 %a)
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
declare i32 @foo(i32)
|
||||
...
|
||||
---
|
||||
name: test
|
||||
tracksRegLiveness: true
|
||||
liveins:
|
||||
- { reg: '%a0' }
|
||||
frameInfo:
|
||||
stackSize: 24
|
||||
maxAlignment: 4
|
||||
adjustsStack: true
|
||||
hasCalls: true
|
||||
maxCallFrameSize: 16
|
||||
stack:
|
||||
- { id: 0, type: spill-slot, offset: -4, size: 4, alignment: 4,
|
||||
callee-saved-register: '%ra' }
|
||||
body: |
|
||||
bb.0.entry:
|
||||
liveins: %a0, %ra
|
||||
|
||||
Save16 %ra, 24, implicit-def %sp, implicit %sp
|
||||
%v0, %v1 = GotPrologue16 $_gp_disp, $_gp_disp
|
||||
%v0 = SllX16 killed %v0, 16
|
||||
%v0 = AdduRxRyRz16 killed %v1, killed %v0
|
||||
; CHECK: [[@LINE+1]]:67: expected a global value or an external symbol after 'call-entry'
|
||||
%v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from call-entry foo)
|
||||
%t9 = COPY %v1
|
||||
%gp = COPY killed %v0
|
||||
JumpLinkReg16 killed %v1, csr_o32, implicit-def %ra, implicit killed %t9, implicit %a0, implicit killed %gp, implicit-def %sp, implicit-def dead %v0
|
||||
%v0 = LiRxImmX16 0
|
||||
%ra = Restore16 24, implicit-def %sp, implicit %sp
|
||||
RetRA16 implicit %v0
|
||||
...
|
|
@ -50,8 +50,8 @@ body: |
|
|||
%v0 = SllX16 killed %v0, 16
|
||||
%v0 = AdduRxRyRz16 killed %v1, killed %v0
|
||||
; CHECK-LABEL: name: test
|
||||
; CHECK: %v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from @foo)
|
||||
%v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from @foo)
|
||||
; CHECK: %v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from call-entry @foo)
|
||||
%v1 = LwRxRyOffMemX16 %v0, @foo, 0 :: (load 4 from call-entry @foo)
|
||||
%t9 = COPY %v1
|
||||
%gp = COPY killed %v0
|
||||
JumpLinkReg16 killed %v1, csr_o32, implicit-def %ra, implicit killed %t9, implicit %a0, implicit killed %gp, implicit-def %sp, implicit-def dead %v0
|
||||
|
@ -87,13 +87,13 @@ body: |
|
|||
%v0, %v1 = GotPrologue16 $_gp_disp, $_gp_disp
|
||||
%v0 = SllX16 killed %v0, 16
|
||||
%s0 = AdduRxRyRz16 killed %v1, killed %v0
|
||||
%v0 = LwRxRyOffMemX16 %s0, @g, 0 :: (load 4 from @g)
|
||||
%v0 = LwRxRyOffMemX16 %s0, @g, 0 :: (load 4 from call-entry @g)
|
||||
; CHECK-LABEL: test2
|
||||
; CHECK: %v1 = LwRxRyOffMemX16 %s0, $__mips16_call_stub_sf_0, 0 :: (load 4 from $__mips16_call_stub_sf_0)
|
||||
%v1 = LwRxRyOffMemX16 %s0, $__mips16_call_stub_sf_0, 0 :: (load 4 from $__mips16_call_stub_sf_0)
|
||||
; CHECK: %v1 = LwRxRyOffMemX16 %s0, $__mips16_call_stub_sf_0, 0 :: (load 4 from call-entry $__mips16_call_stub_sf_0)
|
||||
%v1 = LwRxRyOffMemX16 %s0, $__mips16_call_stub_sf_0, 0 :: (load 4 from call-entry $__mips16_call_stub_sf_0)
|
||||
%gp = COPY %s0
|
||||
JumpLinkReg16 killed %v1, csr_o32, implicit-def %ra, implicit %v0, implicit killed %gp, implicit-def %sp, implicit-def %v0
|
||||
%v1 = LwRxRyOffMemX16 %s0, @__mips16_ret_sf, 0 :: (load 4 from @__mips16_ret_sf)
|
||||
%v1 = LwRxRyOffMemX16 %s0, @__mips16_ret_sf, 0 :: (load 4 from call-entry @__mips16_ret_sf)
|
||||
%t9 = COPY %v1
|
||||
%gp = COPY killed %s0
|
||||
JumpLinkReg16 killed %v1, csr_mips16rethelper, implicit-def %ra, implicit killed %t9, implicit %v0, implicit killed %gp, implicit-def %sp
|
||||
|
|
Loading…
Reference in New Issue