llvm.org GIT mirror llvm / da10a46
[AMDGPU][llvm-mc] Predefined symbols to access -mcpu from the assembly source (.option.machine_version...) The feature allows for conditional assembly etc. TODO: make those symbols read-only. Test added. Differential Revision: http://reviews.llvm.org/D21238 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272673 91177308-0d34-0410-b5e6-96231b3b80d8 Artem Tamazov 4 years ago
2 changed file(s) with 63 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
5959 public:
6060 AMDGPUOperand(enum KindTy K) : MCParsedAsmOperand(), Kind(K) {}
6161
62 MCContext *Ctx;
63
6462 typedef std::unique_ptr Ptr;
6563
6664 struct Modifiers {
585583 }
586584
587585 setAvailableFeatures(ComputeAvailableFeatures(getSTI().getFeatureBits()));
586
587 {
588 // TODO: make those pre-defined variables read-only.
589 // Currently there is none suitable machinery in the core llvm-mc for this.
590 // MCSymbol::isRedefinable is intended for another purpose, and
591 // AsmParser::parseDirectiveSet() cannot be specialized for specific target.
592 AMDGPU::IsaVersion Isa = AMDGPU::getIsaVersion(getSTI().getFeatureBits());
593 MCContext &Ctx = getContext();
594 MCSymbol *Sym = Ctx.getOrCreateSymbol(Twine(".option.machine_version_major"));
595 Sym->setVariableValue(MCConstantExpr::create(Isa.Major, Ctx));
596 Sym = Ctx.getOrCreateSymbol(Twine(".option.machine_version_minor"));
597 Sym->setVariableValue(MCConstantExpr::create(Isa.Minor, Ctx));
598 Sym = Ctx.getOrCreateSymbol(Twine(".option.machine_version_stepping"));
599 Sym->setVariableValue(MCConstantExpr::create(Isa.Stepping, Ctx));
600 }
588601 }
589602
590603 AMDGPUTargetStreamer &getTargetStreamer() {
0 // RUN: llvm-mc -arch=amdgcn -mcpu=bonaire %s | FileCheck %s --check-prefix=BONAIRE
1 // RUN: llvm-mc -arch=amdgcn -mcpu=hawaii %s | FileCheck %s --check-prefix=HAWAII
2 // RUN: llvm-mc -arch=amdgcn -mcpu=tonga %s | FileCheck %s --check-prefix=TONGA
3 // RUN: llvm-mc -arch=amdgcn -mcpu=fiji %s | FileCheck %s --check-prefix=FIJI
4
5 .if .option.machine_version_major == 0
6 .byte 0
7 .elseif .option.machine_version_major == 7
8 .byte 7
9 .elseif .option.machine_version_major == 8
10 .byte 8
11 .else
12 .error "major unknown"
13 .endif
14 // BONAIRE: .byte 7
15 // HAWAII: .byte 7
16 // TONGA: .byte 8
17 // FIJI: .byte 8
18
19 .if .option.machine_version_minor == 0
20 .byte 0
21 .else
22 .error "minor unknown"
23 .endif
24 // BONAIRE: .byte 0
25 // HAWAII: .byte 0
26 // TONGA: .byte 0
27 // FIJI: .byte 0
28
29 .if .option.machine_version_stepping == 0
30 .byte 0
31 .elseif .option.machine_version_stepping == 1
32 .byte 1
33 .elseif .option.machine_version_stepping == 3
34 .byte 3
35 .else
36 .error "stepping unknown"
37 .endif
38 // BONAIRE: .byte 0
39 // HAWAII: .byte 1
40 // TONGA: .byte 0
41 // FIJI: .byte 3
42
43 v_add_f32 v0, v0, v[.option.machine_version_major]
44 // BONAIRE: v_add_f32_e32 v0, v0, v7
45 // HAWAII: v_add_f32_e32 v0, v0, v7
46 // TONGA: v_add_f32_e32 v0, v0, v8
47 // FIJI: v_add_f32_e32 v0, v0, v8