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 const MCTargetOptions &Options)
26 : MCAsmInfoELF(Options) {
27 AssemblerDialect = AD_GNU;
28 CalleeSaveStackSlotSize = 8;
29 CodePointerSize = 8;
30 Data64bitsDirective = "\t.quad\t";
31 ExceptionsType = ExceptionHandling::DwarfCFI;
32 IsLittleEndian = false;
33 MaxInstLength = 6;
34 SupportsDebugInformation = true;
35 UsesELFSectionDirectiveForBSS = true;
36 ZeroDirective = "\t.space\t";
37
38 initializeAtSpecifiers(atSpecifiers);
39}
40
41SystemZMCAsmInfoGOFF::SystemZMCAsmInfoGOFF(const Triple &TT,
42 const MCTargetOptions &Options)
43 : MCAsmInfoGOFF(Options) {
44 AllowAdditionalComments = false;
45 AllowAtInName = true;
46 AllowAtAtStartOfIdentifier = true;
47 AllowDollarAtStartOfIdentifier = true;
48 AssemblerDialect = AD_HLASM;
49 CalleeSaveStackSlotSize = 8;
50 CodePointerSize = 8;
51 CommentString = "*";
52 UsesSetToEquateSymbol = true;
53 ExceptionsType = ExceptionHandling::ZOS;
54 IsHLASM = true;
55 IsLittleEndian = false;
56 MaxInstLength = 6;
57 SupportsDebugInformation = true;
58
59 initializeAtSpecifiers(atSpecifiers);
60}
61
62bool SystemZMCAsmInfoGOFF::isAcceptableChar(char C) const {
63 return MCAsmInfo::isAcceptableChar(C) || C == '#';
64}
65
66void SystemZMCAsmInfoGOFF::printSpecifierExpr(
67 raw_ostream &OS, const MCSpecifierExpr &Expr) const {
68 switch (Expr.getSpecifier()) {
69 case SystemZ::S_None:
70 OS << "AD";
71 break;
72 case SystemZ::S_QCon:
73 OS << "QD";
74 break;
75 case SystemZ::S_RCon:
76 OS << "RD";
77 break;
78 case SystemZ::S_VCon:
79 OS << "VD";
80 break;
81 default:
82 llvm_unreachable("Invalid kind");
83 }
84 OS << '(';
85 printExpr(OS, *Expr.getSubExpr());
86 OS << ')';
87}
88
89bool SystemZMCAsmInfoGOFF::evaluateAsRelocatableImpl(
90 const MCSpecifierExpr &Expr, MCValue &Res, const MCAssembler *Asm) const {
91 if (!Expr.getSubExpr()->evaluateAsRelocatable(Res, Asm))
92 return false;
93 Res.setSpecifier(Expr.getSpecifier());
94 return true;
95}
96