mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-24 22:24:54 +00:00
MIR Serialization: Serialize the metadata machine operands.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@242916 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -310,6 +310,8 @@ static MIToken::TokenKind symbolToken(char C) {
|
|||||||
return MIToken::equal;
|
return MIToken::equal;
|
||||||
case ':':
|
case ':':
|
||||||
return MIToken::colon;
|
return MIToken::colon;
|
||||||
|
case '!':
|
||||||
|
return MIToken::exclaim;
|
||||||
default:
|
default:
|
||||||
return MIToken::Error;
|
return MIToken::Error;
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,7 @@ struct MIToken {
|
|||||||
equal,
|
equal,
|
||||||
underscore,
|
underscore,
|
||||||
colon,
|
colon,
|
||||||
|
exclaim,
|
||||||
|
|
||||||
// Keywords
|
// Keywords
|
||||||
kw_implicit,
|
kw_implicit,
|
||||||
|
@@ -112,6 +112,7 @@ public:
|
|||||||
bool parseConstantPoolIndexOperand(MachineOperand &Dest);
|
bool parseConstantPoolIndexOperand(MachineOperand &Dest);
|
||||||
bool parseJumpTableIndexOperand(MachineOperand &Dest);
|
bool parseJumpTableIndexOperand(MachineOperand &Dest);
|
||||||
bool parseExternalSymbolOperand(MachineOperand &Dest);
|
bool parseExternalSymbolOperand(MachineOperand &Dest);
|
||||||
|
bool parseMetadataOperand(MachineOperand &Dest);
|
||||||
bool parseCFIOffset(int &Offset);
|
bool parseCFIOffset(int &Offset);
|
||||||
bool parseCFIOperand(MachineOperand &Dest);
|
bool parseCFIOperand(MachineOperand &Dest);
|
||||||
bool parseMachineOperand(MachineOperand &Dest);
|
bool parseMachineOperand(MachineOperand &Dest);
|
||||||
@@ -575,6 +576,23 @@ bool MIParser::parseExternalSymbolOperand(MachineOperand &Dest) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MIParser::parseMetadataOperand(MachineOperand &Dest) {
|
||||||
|
assert(Token.is(MIToken::exclaim));
|
||||||
|
auto Loc = Token.location();
|
||||||
|
lex();
|
||||||
|
if (Token.isNot(MIToken::IntegerLiteral) || Token.integerValue().isSigned())
|
||||||
|
return error("expected metadata id after '!'");
|
||||||
|
unsigned ID;
|
||||||
|
if (getUnsigned(ID))
|
||||||
|
return true;
|
||||||
|
auto NodeInfo = IRSlots.MetadataNodes.find(ID);
|
||||||
|
if (NodeInfo == IRSlots.MetadataNodes.end())
|
||||||
|
return error(Loc, "use of undefined metadata '!" + Twine(ID) + "'");
|
||||||
|
lex();
|
||||||
|
Dest = MachineOperand::CreateMetadata(NodeInfo->second.get());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool MIParser::parseCFIOffset(int &Offset) {
|
bool MIParser::parseCFIOffset(int &Offset) {
|
||||||
if (Token.isNot(MIToken::IntegerLiteral))
|
if (Token.isNot(MIToken::IntegerLiteral))
|
||||||
return error("expected a cfi offset");
|
return error("expected a cfi offset");
|
||||||
@@ -628,6 +646,8 @@ bool MIParser::parseMachineOperand(MachineOperand &Dest) {
|
|||||||
case MIToken::ExternalSymbol:
|
case MIToken::ExternalSymbol:
|
||||||
case MIToken::QuotedExternalSymbol:
|
case MIToken::QuotedExternalSymbol:
|
||||||
return parseExternalSymbolOperand(Dest);
|
return parseExternalSymbolOperand(Dest);
|
||||||
|
case MIToken::exclaim:
|
||||||
|
return parseMetadataOperand(Dest);
|
||||||
case MIToken::kw_cfi_def_cfa_offset:
|
case MIToken::kw_cfi_def_cfa_offset:
|
||||||
return parseCFIOperand(Dest);
|
return parseCFIOperand(Dest);
|
||||||
case MIToken::Error:
|
case MIToken::Error:
|
||||||
|
@@ -453,6 +453,9 @@ void MIPrinter::print(const MachineOperand &Op, const TargetRegisterInfo *TRI) {
|
|||||||
llvm_unreachable("Can't print this machine register mask yet.");
|
llvm_unreachable("Can't print this machine register mask yet.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case MachineOperand::MO_Metadata:
|
||||||
|
Op.getMetadata()->printAsOperand(OS, MST);
|
||||||
|
break;
|
||||||
case MachineOperand::MO_CFIIndex: {
|
case MachineOperand::MO_CFIIndex: {
|
||||||
const auto &MMI = Op.getParent()->getParent()->getParent()->getMMI();
|
const auto &MMI = Op.getParent()->getParent()->getParent()->getMMI();
|
||||||
print(MMI.getFrameInstructions()[Op.getCFIIndex()]);
|
print(MMI.getFrameInstructions()[Op.getCFIIndex()]);
|
||||||
|
@@ -0,0 +1,61 @@
|
|||||||
|
# RUN: not llc -march=x86-64 -start-after machine-sink -stop-after machine-sink -o /dev/null %s 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
--- |
|
||||||
|
|
||||||
|
define i32 @test(i32 %x) #0 {
|
||||||
|
entry:
|
||||||
|
%x.addr = alloca i32, align 4
|
||||||
|
store i32 %x, i32* %x.addr, align 4
|
||||||
|
call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14
|
||||||
|
%0 = load i32, i32* %x.addr, align 4, !dbg !15
|
||||||
|
ret i32 %0, !dbg !15
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
||||||
|
|
||||||
|
attributes #0 = { nounwind "no-frame-pointer-elim"="false" }
|
||||||
|
attributes #1 = { nounwind readnone }
|
||||||
|
|
||||||
|
!llvm.dbg.cu = !{!0}
|
||||||
|
!llvm.module.flags = !{!9, !10}
|
||||||
|
!llvm.ident = !{!11}
|
||||||
|
|
||||||
|
!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
|
||||||
|
!1 = !DIFile(filename: "test.ll", directory: "")
|
||||||
|
!2 = !{}
|
||||||
|
!3 = !{!4}
|
||||||
|
!4 = !DISubprogram(name: "test", scope: !5, file: !5, line: 4, type: !6, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @test, variables: !2)
|
||||||
|
!5 = !DIFile(filename: "test.c", directory: "")
|
||||||
|
!6 = !DISubroutineType(types: !7)
|
||||||
|
!7 = !{!8, !8}
|
||||||
|
!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
||||||
|
!9 = !{i32 2, !"Dwarf Version", i32 4}
|
||||||
|
!10 = !{i32 2, !"Debug Info Version", i32 3}
|
||||||
|
!11 = !{!"clang version 3.7.0"}
|
||||||
|
!12 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8)
|
||||||
|
!13 = !DIExpression()
|
||||||
|
!14 = !DILocation(line: 4, scope: !4)
|
||||||
|
!15 = !DILocation(line: 8, scope: !4)
|
||||||
|
|
||||||
|
...
|
||||||
|
---
|
||||||
|
name: test
|
||||||
|
isSSA: true
|
||||||
|
tracksRegLiveness: true
|
||||||
|
registers:
|
||||||
|
- { id: 0, class: gr32 }
|
||||||
|
frameInfo:
|
||||||
|
maxAlignment: 4
|
||||||
|
stack:
|
||||||
|
- { id: 0, name: x.addr, size: 4, alignment: 4 }
|
||||||
|
body:
|
||||||
|
- id: 0
|
||||||
|
name: entry
|
||||||
|
instructions:
|
||||||
|
- '%0 = COPY %edi'
|
||||||
|
# CHECK: [[@LINE+1]]:33: expected metadata id after '!'
|
||||||
|
- 'DBG_VALUE _, 0, !12, ! _'
|
||||||
|
- 'MOV32mr %stack.0.x.addr, 1, _, 0, _, %0'
|
||||||
|
- '%eax = COPY %0'
|
||||||
|
- 'RETQ %eax'
|
||||||
|
...
|
64
test/CodeGen/MIR/X86/metadata-operands.mir
Normal file
64
test/CodeGen/MIR/X86/metadata-operands.mir
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
# RUN: llc -march=x86-64 -start-after machine-sink -stop-after machine-sink -o /dev/null %s | FileCheck %s
|
||||||
|
# This test ensures that the MIR parser parses the metadata machine operands
|
||||||
|
# correctly.
|
||||||
|
|
||||||
|
--- |
|
||||||
|
|
||||||
|
define i32 @test(i32 %x) #0 {
|
||||||
|
entry:
|
||||||
|
%x.addr = alloca i32, align 4
|
||||||
|
store i32 %x, i32* %x.addr, align 4
|
||||||
|
call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14
|
||||||
|
%0 = load i32, i32* %x.addr, align 4, !dbg !15
|
||||||
|
ret i32 %0, !dbg !15
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
||||||
|
|
||||||
|
attributes #0 = { nounwind "no-frame-pointer-elim"="false" }
|
||||||
|
attributes #1 = { nounwind readnone }
|
||||||
|
|
||||||
|
!llvm.dbg.cu = !{!0}
|
||||||
|
!llvm.module.flags = !{!9, !10}
|
||||||
|
!llvm.ident = !{!11}
|
||||||
|
|
||||||
|
!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
|
||||||
|
!1 = !DIFile(filename: "test.ll", directory: "")
|
||||||
|
!2 = !{}
|
||||||
|
!3 = !{!4}
|
||||||
|
!4 = !DISubprogram(name: "test", scope: !5, file: !5, line: 4, type: !6, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @test, variables: !2)
|
||||||
|
!5 = !DIFile(filename: "test.c", directory: "")
|
||||||
|
!6 = !DISubroutineType(types: !7)
|
||||||
|
!7 = !{!8, !8}
|
||||||
|
!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
||||||
|
!9 = !{i32 2, !"Dwarf Version", i32 4}
|
||||||
|
!10 = !{i32 2, !"Debug Info Version", i32 3}
|
||||||
|
!11 = !{!"clang version 3.7.0"}
|
||||||
|
!12 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8)
|
||||||
|
!13 = !DIExpression()
|
||||||
|
!14 = !DILocation(line: 4, scope: !4)
|
||||||
|
!15 = !DILocation(line: 8, scope: !4)
|
||||||
|
|
||||||
|
...
|
||||||
|
---
|
||||||
|
name: test
|
||||||
|
isSSA: true
|
||||||
|
tracksRegLiveness: true
|
||||||
|
registers:
|
||||||
|
- { id: 0, class: gr32 }
|
||||||
|
frameInfo:
|
||||||
|
maxAlignment: 4
|
||||||
|
stack:
|
||||||
|
- { id: 0, name: x.addr, size: 4, alignment: 4 }
|
||||||
|
body:
|
||||||
|
- id: 0
|
||||||
|
name: entry
|
||||||
|
instructions:
|
||||||
|
# CHECK: %0 = COPY %edi
|
||||||
|
# CHECK-NEXT: DBG_VALUE _, 0, !12, !13
|
||||||
|
- '%0 = COPY %edi'
|
||||||
|
- 'DBG_VALUE _, 0, !12, ! 13'
|
||||||
|
- 'MOV32mr %stack.0.x.addr, 1, _, 0, _, %0'
|
||||||
|
- '%eax = COPY %0'
|
||||||
|
- 'RETQ %eax'
|
||||||
|
...
|
61
test/CodeGen/MIR/X86/unknown-metadata-node.mir
Normal file
61
test/CodeGen/MIR/X86/unknown-metadata-node.mir
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
# RUN: not llc -march=x86-64 -start-after machine-sink -stop-after machine-sink -o /dev/null %s 2>&1 | FileCheck %s
|
||||||
|
|
||||||
|
--- |
|
||||||
|
|
||||||
|
define i32 @test(i32 %x) #0 {
|
||||||
|
entry:
|
||||||
|
%x.addr = alloca i32, align 4
|
||||||
|
store i32 %x, i32* %x.addr, align 4
|
||||||
|
call void @llvm.dbg.declare(metadata i32* %x.addr, metadata !12, metadata !13), !dbg !14
|
||||||
|
%0 = load i32, i32* %x.addr, align 4, !dbg !15
|
||||||
|
ret i32 %0, !dbg !15
|
||||||
|
}
|
||||||
|
|
||||||
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
||||||
|
|
||||||
|
attributes #0 = { nounwind "no-frame-pointer-elim"="false" }
|
||||||
|
attributes #1 = { nounwind readnone }
|
||||||
|
|
||||||
|
!llvm.dbg.cu = !{!0}
|
||||||
|
!llvm.module.flags = !{!9, !10}
|
||||||
|
!llvm.ident = !{!11}
|
||||||
|
|
||||||
|
!0 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.7.0", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !2, subprograms: !3, globals: !2, imports: !2)
|
||||||
|
!1 = !DIFile(filename: "test.ll", directory: "")
|
||||||
|
!2 = !{}
|
||||||
|
!3 = !{!4}
|
||||||
|
!4 = !DISubprogram(name: "test", scope: !5, file: !5, line: 4, type: !6, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, function: i32 (i32)* @test, variables: !2)
|
||||||
|
!5 = !DIFile(filename: "test.c", directory: "")
|
||||||
|
!6 = !DISubroutineType(types: !7)
|
||||||
|
!7 = !{!8, !8}
|
||||||
|
!8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
||||||
|
!9 = !{i32 2, !"Dwarf Version", i32 4}
|
||||||
|
!10 = !{i32 2, !"Debug Info Version", i32 3}
|
||||||
|
!11 = !{!"clang version 3.7.0"}
|
||||||
|
!12 = !DILocalVariable(tag: DW_TAG_arg_variable, name: "x", arg: 1, scope: !4, file: !5, line: 4, type: !8)
|
||||||
|
!13 = !DIExpression()
|
||||||
|
!14 = !DILocation(line: 4, scope: !4)
|
||||||
|
!15 = !DILocation(line: 8, scope: !4)
|
||||||
|
|
||||||
|
...
|
||||||
|
---
|
||||||
|
name: test
|
||||||
|
isSSA: true
|
||||||
|
tracksRegLiveness: true
|
||||||
|
registers:
|
||||||
|
- { id: 0, class: gr32 }
|
||||||
|
frameInfo:
|
||||||
|
maxAlignment: 4
|
||||||
|
stack:
|
||||||
|
- { id: 0, name: x.addr, size: 4, alignment: 4 }
|
||||||
|
body:
|
||||||
|
- id: 0
|
||||||
|
name: entry
|
||||||
|
instructions:
|
||||||
|
- '%0 = COPY %edi'
|
||||||
|
# CHECK: [[@LINE+1]]:26: use of undefined metadata '!42'
|
||||||
|
- 'DBG_VALUE _, 0, !42, !13'
|
||||||
|
- 'MOV32mr %stack.0.x.addr, 1, _, 0, _, %0'
|
||||||
|
- '%eax = COPY %0'
|
||||||
|
- 'RETQ %eax'
|
||||||
|
...
|
Reference in New Issue
Block a user