xref: /llvm-project/llvm/test/CodeGen/DirectX/embed-dxil.ll (revision 531a0b67ea1ad65ea4d1a99c67fee280beeb8fbb)
1; RUN: opt %s -dxil-embed -S -o - | FileCheck %s
2; RUN: llc %s --filetype=obj -o - | obj2yaml | FileCheck %s --check-prefix=DXC
3target triple = "dxil-unknown-shadermodel6.5-library"
4
5; Make sure triple is restored after updated to dxil.
6; CHECK:target triple = "dxil-unknown-shadermodel6.5-library"
7
8define i32 @add(i32 %a, i32 %b) {
9  %sum = add i32 %a, %b
10  ret i32 %sum
11}
12
13; CHECK: @dx.dxil = private constant [[BC_TYPE:\[[0-9]+ x i8\]]] c"BC\C0\DE{{[^"]+}}", section "DXIL", align 4
14
15; The dxil global should be the first here because we generate it before the
16; other globals. If it isn't the first here, that's probably a bug.
17; CHECK: @llvm.compiler.used = appending global {{\[[0-9]+ x ptr\]}} [ptr @dx.dxil
18
19; This is using regex matches on some sizes, offsets and fields. These are all
20; going to change as the DirectX backend continues to evolve and implement more
21; features. Rather than extending this test to cover those future features, this
22; test's matches are extremely fuzzy so that it won't break.
23
24; DXC: --- !dxcontainer
25; DXC-NEXT: Header:
26; DXC-NEXT:   Hash:            [ 0x0, 0x0, 0x0,
27; DXC:   Version:
28; DXC-NEXT:     Major:           1
29; DXC-NEXT:     Minor:           0
30; DXC-NEXT:   FileSize:        [[#]]
31; DXC-NEXT:   PartCount:       [[#]]
32; DXC-NEXT:   PartOffsets:     [ {{[0-9, ]+}} ]
33; DXC-NEXT: Parts:
34
35; In verifying the DXIL part, this test captures the size of the part, and
36; derives the program header and dxil size fields from the part's size.
37
38; DXC:   - Name:            DXIL
39; DXC-NEXT:     Size:            [[#SIZE:]]
40; DXC-NEXT:     Program:
41; DXC-NEXT:       MajorVersion:    6
42; DXC-NEXT:       MinorVersion:    5
43; DXC-NEXT:       ShaderKind:      6
44; DXC-NEXT:       Size:            [[#div(SIZE,4)]]
45; DXC-NEXT:       DXILMajorVersion: 1
46; DXC-NEXT:       DXILMinorVersion: 5
47; DXC-NEXT:       DXILSize:        [[#SIZE - 24]]
48; DXC-NEXT:       DXIL:            [ 0x42, 0x43, 0xC0, 0xDE,
49; DXC:      - Name:            SFI0
50; DXC-NEXT:   Size:            8
51; DXC-NOT:    Flags:
52