1//===-- SystemZMCAsmInfo.cpp - SystemZ asm properties ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "SystemZMCAsmInfo.h"
10#include "llvm/MC/MCContext.h"
11#include "llvm/MC/MCExpr.h"
12#include "llvm/MC/MCValue.h"
13
14using namespace llvm;
15
16const MCAsmInfo::AtSpecifier atSpecifiers[] = {
17 {.Kind: SystemZ::S_DTPOFF, .Name: "DTPOFF"}, {.Kind: SystemZ::S_GOT, .Name: "GOT"},
18 {.Kind: SystemZ::S_GOTENT, .Name: "GOTENT"}, {.Kind: SystemZ::S_INDNTPOFF, .Name: "INDNTPOFF"},
19 {.Kind: SystemZ::S_NTPOFF, .Name: "NTPOFF"}, {.Kind: SystemZ::S_PLT, .Name: "PLT"},
20 {.Kind: SystemZ::S_TLSGD, .Name: "TLSGD"}, {.Kind: SystemZ::S_TLSLD, .Name: "TLSLD"},
21 {.Kind: SystemZ::S_TLSLDM, .Name: "TLSLDM"},
22};
23
24SystemZMCAsmInfoELF::SystemZMCAsmInfoELF(const Triple &TT) {
25 AssemblerDialect = AD_GNU;
26 CalleeSaveStackSlotSize = 8;
27 CodePointerSize = 8;
28 Data64bitsDirective = "\t.quad\t";
29 ExceptionsType = ExceptionHandling::DwarfCFI;
30 IsLittleEndian = false;
31 MaxInstLength = 6;
32 SupportsDebugInformation = true;
33 UsesELFSectionDirectiveForBSS = true;
34 ZeroDirective = "\t.space\t";
35
36 initializeAtSpecifiers(atSpecifiers);
37}
38
39SystemZMCAsmInfoGOFF::SystemZMCAsmInfoGOFF(const Triple &TT) {
40 AllowAdditionalComments = false;
41 AllowAtInName = true;
42 AllowAtAtStartOfIdentifier = true;
43 AllowDollarAtStartOfIdentifier = true;
44 AssemblerDialect = AD_HLASM;
45 CalleeSaveStackSlotSize = 8;
46 CodePointerSize = 8;
47 CommentString = "*";
48 UsesSetToEquateSymbol = true;
49 ExceptionsType = ExceptionHandling::ZOS;
50 IsHLASM = true;
51 IsLittleEndian = false;
52 MaxInstLength = 6;
53 SupportsDebugInformation = true;
54
55 initializeAtSpecifiers(atSpecifiers);
56}
57
58bool SystemZMCAsmInfoGOFF::isAcceptableChar(char C) const {
59 return MCAsmInfo::isAcceptableChar(C) || C == '#';
60}
61
62void SystemZMCAsmInfoGOFF::printSpecifierExpr(
63 raw_ostream &OS, const MCSpecifierExpr &Expr) const {
64 switch (Expr.getSpecifier()) {
65 case SystemZ::S_None:
66 OS << "A";
67 break;
68 case SystemZ::S_RCon:
69 OS << "R";
70 break;
71 case SystemZ::S_VCon:
72 OS << "V";
73 break;
74 default:
75 llvm_unreachable("Invalid kind");
76 }
77 OS << '(';
78 printExpr(OS, *Expr.getSubExpr());
79 OS << ')';
80}
81
82bool SystemZMCAsmInfoGOFF::evaluateAsRelocatableImpl(
83 const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const {
84 if (!Expr.getSubExpr()->evaluateAsRelocatable(Res, Asm))
85 return false;
86 Res.setSpecifier(Expr.getSpecifier());
87 return true;
88}
89