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/ADT/Enum.h"
11#include "llvm/MC/MCContext.h"
12#include "llvm/MC/MCExpr.h"
13#include "llvm/MC/MCValue.h"
14
15using namespace llvm;
16
17constexpr EnumStringDef<MCAsmInfo::AtSpecifierKind> AtSpecifierDefs[] = {
18 {.Names: {"DTPOFF"}, .Value: SystemZ::S_DTPOFF}, {.Names: {"GOT"}, .Value: SystemZ::S_GOT},
19 {.Names: {"GOTENT"}, .Value: SystemZ::S_GOTENT}, {.Names: {"INDNTPOFF"}, .Value: SystemZ::S_INDNTPOFF},
20 {.Names: {"NTPOFF"}, .Value: SystemZ::S_NTPOFF}, {.Names: {"PLT"}, .Value: SystemZ::S_PLT},
21 {.Names: {"TLSGD"}, .Value: SystemZ::S_TLSGD}, {.Names: {"TLSLD"}, .Value: SystemZ::S_TLSLD},
22 {.Names: {"TLSLDM"}, .Value: SystemZ::S_TLSLDM},
23};
24constexpr auto atSpecifiers = BUILD_ENUM_STRINGS(AtSpecifierDefs);
25
26SystemZMCAsmInfoELF::SystemZMCAsmInfoELF(const Triple &TT,
27 const MCTargetOptions &Options)
28 : MCAsmInfoELF(Options) {
29 AssemblerDialect = AD_GNU;
30 CalleeSaveStackSlotSize = 8;
31 CodePointerSize = 8;
32 Data64bitsDirective = "\t.quad\t";
33 ExceptionsType = ExceptionHandling::DwarfCFI;
34 IsLittleEndian = false;
35 MaxInstLength = 6;
36 SupportsDebugInformation = true;
37 UsesELFSectionDirectiveForBSS = true;
38 ZeroDirective = "\t.space\t";
39
40 initializeAtSpecifiers(atSpecifiers);
41}
42
43SystemZMCAsmInfoGOFF::SystemZMCAsmInfoGOFF(const Triple &TT,
44 const MCTargetOptions &Options)
45 : MCAsmInfoGOFF(Options) {
46 AllowAdditionalComments = false;
47 AllowAtInName = true;
48 AllowAtAtStartOfIdentifier = true;
49 AllowDollarAtStartOfIdentifier = true;
50 AssemblerDialect = AD_HLASM;
51 CalleeSaveStackSlotSize = 8;
52 CodePointerSize = 8;
53 CommentString = "*";
54 UsesSetToEquateSymbol = true;
55 ExceptionsType = ExceptionHandling::ZOS;
56 IsHLASM = true;
57 IsLittleEndian = false;
58 MaxInstLength = 6;
59 SupportsDebugInformation = true;
60
61 initializeAtSpecifiers(atSpecifiers);
62}
63
64void SystemZMCAsmInfoGOFF::printSpecifierExpr(
65 raw_ostream &OS, const MCSpecifierExpr &Expr) const {
66 switch (Expr.getSpecifier()) {
67 case SystemZ::S_None:
68 OS << "AD";
69 break;
70 case SystemZ::S_QCon:
71 OS << "QD";
72 break;
73 case SystemZ::S_RCon:
74 OS << "RD";
75 break;
76 case SystemZ::S_VCon:
77 OS << "VD";
78 break;
79 default:
80 llvm_unreachable("Invalid kind");
81 }
82 OS << '(';
83 printExpr(OS, *Expr.getSubExpr());
84 OS << ')';
85}
86
87bool SystemZMCAsmInfoGOFF::evaluateAsRelocatableImpl(
88 const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const {
89 if (!Expr.getSubExpr()->evaluateAsRelocatable(Res, Asm))
90 return false;
91 Res.setSpecifier(Expr.getSpecifier());
92 return true;
93}
94