1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 11:42:57 +01:00
llvm-mirror/test/CodeGen/MIR/X86/instr-symbols-and-mcsymbol-operands.mir
Chandler Carruth 1c07e3e377 [x86/MIR] Implement support for pre- and post-instruction symbols, as
well as MIR parsing support for `MCSymbol` `MachineOperand`s.

The only real way to test pre- and post-instruction symbol support is to
use them in operands, so I ended up implementing that within the patch
as well. I can split out the operand support if folks really want but it
doesn't really seem worth it.

The functional implementation of pre- and post-instruction symbols is
now *completely trivial*. Two tiny bits of code in the (misnamed)
AsmPrinter. It should be completely target independent as well. We emit
these exactly the same way as we emit basic block labels. Most of the
code here is to give full dumping, MIR printing, and MIR parsing support
so that we can write useful tests.

The MIR parsing of MC symbol operands still isn't 100%, as it forces the
symbols to be non-temporary and non-local symbols with names. However,
those names often can encode most (if not all) of the special semantics
desired, and unnamed symbols seem especially annoying to serialize and
de-serialize. While this isn't perfect or full support, it seems plenty
to write tests that exercise usage of these kinds of operands.

The MIR support for pre-and post-instruction symbols was quite
straightforward. I chose to print them out in an as-if-operand syntax
similar to debug locations as this seemed the cleanest way and let me
use nice introducer tokens rather than inventing more magic punctuation
like we use for memoperands.

However, supporting MIR-based parsing of these symbols caused me to
change the design of the symbol support to allow setting arbitrary
symbols. Without this, I don't see any reasonable way to test things
with MIR.

Differential Revision: https://reviews.llvm.org/D50833

llvm-svn: 339962
2018-08-16 23:11:05 +00:00

83 lines
3.3 KiB
YAML

# RUN: llc -march=x86-64 -run-pass none -o - %s | FileCheck %s
# This test ensures that the MIR parser parses pre- and post-instruction symbols
# and MCSymbol operands correctly.
--- |
declare void @f(i32 %x) nounwind
declare void @g(i32 %x) nounwind
declare void @h(i32 %x) nounwind
define i64 @test(i32 %x) nounwind {
entry:
call void @f(i32 %x)
call void @g(i32 %x)
call void @h(i32 %x), !dbg !9
ret i64 undef
}
!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!6, !7}
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !2, globals: !2, imports: !2)
!1 = !DIFile(filename: "test.ll", directory: "")
!2 = !{}
!4 = distinct !DISubprogram(name: "test", scope: !5, file: !5, line: 4, type: !2, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2)
!5 = !DIFile(filename: "test.c", directory: "")
!6 = !{i32 2, !"Dwarf Version", i32 4}
!7 = !{i32 2, !"Debug Info Version", i32 3}
!9 = !DILocation(line: 1, scope: !4)
...
---
name: test
# CHECK-LABEL: name: test
tracksRegLiveness: true
frameInfo:
hasCalls: true
body: |
bb.0.entry:
liveins: $edi
%0:gr32 = COPY $edi
%1:gr32 = COPY killed %0
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
$edi = COPY %1
CALL64pcrel32 @f, csr_64, implicit $rsp, implicit $ssp, implicit $edi, pre-instr-symbol <mcsymbol .Lpre_f>, post-instr-symbol <mcsymbol .Lpost_f>
; CHECK: CALL64pcrel32 @f, {{.*}}, pre-instr-symbol <mcsymbol .Lpre_f>, post-instr-symbol <mcsymbol .Lpost_f>
ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
$edi = COPY %1
CALL64pcrel32 @g, csr_64, implicit $rsp, implicit $ssp, implicit $edi, pre-instr-symbol <mcsymbol .Lpre_g>
; CHECK: CALL64pcrel32 @g, {{.*}}, pre-instr-symbol <mcsymbol .Lpre_g>
ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
ADJCALLSTACKDOWN64 0, 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
$edi = COPY %1
CALL64pcrel32 @h, csr_64, implicit $rsp, implicit $ssp, implicit $edi, post-instr-symbol <mcsymbol .Lpost_h>, debug-location !9
; CHECK: CALL64pcrel32 @h, {{.*}}, post-instr-symbol <mcsymbol .Lpost_h>, debug-location
ADJCALLSTACKUP64 0, 0, implicit-def $rsp, implicit-def $eflags, implicit-def $ssp, implicit $rsp, implicit $ssp
%2:gr64 = MOV64ri32 <mcsymbol .Lpre_f>
%3:gr64 = MOV64ri32 <mcsymbol .Lpost_f>
%4:gr64 = MOV64ri32 <mcsymbol .Lpre_g>
%5:gr64 = MOV64ri32 <mcsymbol .Lpost_h>
; CHECK: %2:gr64 = MOV64ri32 <mcsymbol .Lpre_f>
; CHECK: %3:gr64 = MOV64ri32 <mcsymbol .Lpost_f>
; CHECK: %4:gr64 = MOV64ri32 <mcsymbol .Lpre_g>
; CHECK: %5:gr64 = MOV64ri32 <mcsymbol .Lpost_h>
%6:gr64 = ADD64rr killed %2, killed %3, implicit-def $eflags
%7:gr64 = ADD64rr killed %4, killed %5, implicit-def $eflags
%8:gr64 = ADD64rr killed %6, killed %7, implicit-def $eflags
$rax = COPY %8
RETQ implicit $rax
...