1//===-- ARMMCAsmInfo.h - ARM asm properties --------------------*- C++ -*--===//
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// This file contains the declaration of the ARMMCAsmInfo class.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCASMINFO_H
14#define LLVM_LIB_TARGET_ARM_MCTARGETDESC_ARMMCASMINFO_H
15
16#include "llvm/MC/MCAsmInfoCOFF.h"
17#include "llvm/MC/MCAsmInfoDarwin.h"
18#include "llvm/MC/MCAsmInfoELF.h"
19#include "llvm/MC/MCExpr.h"
20
21namespace llvm {
22class Triple;
23
24namespace ARM {
25void printSpecifierExpr(const MCAsmInfo &MAI, raw_ostream &OS,
26 const MCSpecifierExpr &Expr);
27}
28
29class ARMMCAsmInfoDarwin : public MCAsmInfoDarwin {
30 virtual void anchor();
31
32public:
33 explicit ARMMCAsmInfoDarwin(const Triple &TheTriple,
34 const MCTargetOptions &Options);
35 void printSpecifierExpr(raw_ostream &OS,
36 const MCSpecifierExpr &Expr) const override {
37 ARM::printSpecifierExpr(MAI: *this, OS, Expr);
38 }
39 bool evaluateAsRelocatableImpl(const MCSpecifierExpr &, MCValue &,
40 const MCAssembler *) const override {
41 return false;
42 }
43};
44
45class ARMELFMCAsmInfo : public MCAsmInfoELF {
46 void anchor() override;
47
48public:
49 explicit ARMELFMCAsmInfo(const Triple &TT, const MCTargetOptions &Options);
50
51 void setUseIntegratedAssembler(bool Value) override;
52 void printSpecifierExpr(raw_ostream &OS,
53 const MCSpecifierExpr &Expr) const override {
54 ARM::printSpecifierExpr(MAI: *this, OS, Expr);
55 }
56 bool evaluateAsRelocatableImpl(const MCSpecifierExpr &, MCValue &,
57 const MCAssembler *) const override {
58 return false;
59 }
60 bool usesCompInstByteOrder(const MCSubtargetInfo &STI) const override;
61};
62
63class ARMCOFFMCAsmInfoMicrosoft : public MCAsmInfoMicrosoft {
64 void anchor() override;
65
66public:
67 explicit ARMCOFFMCAsmInfoMicrosoft(const MCTargetOptions &Options);
68 void printSpecifierExpr(raw_ostream &OS,
69 const MCSpecifierExpr &Expr) const override {
70 ARM::printSpecifierExpr(MAI: *this, OS, Expr);
71 }
72 bool evaluateAsRelocatableImpl(const MCSpecifierExpr &, MCValue &,
73 const MCAssembler *) const override {
74 return false;
75 }
76};
77
78class ARMCOFFMCAsmInfoGNU : public MCAsmInfoGNUCOFF {
79 void anchor() override;
80
81public:
82 explicit ARMCOFFMCAsmInfoGNU(const MCTargetOptions &Options);
83 void printSpecifierExpr(raw_ostream &OS,
84 const MCSpecifierExpr &Expr) const override {
85 ARM::printSpecifierExpr(MAI: *this, OS, Expr);
86 }
87 bool evaluateAsRelocatableImpl(const MCSpecifierExpr &, MCValue &,
88 const MCAssembler *) const override {
89 return false;
90 }
91};
92
93namespace ARM {
94using Specifier = uint16_t;
95enum {
96 S_None,
97 S_COFF_SECREL,
98
99 S_HI16 =
100 MCSymbolRefExpr::FirstTargetSpecifier, // The R_ARM_MOVT_ABS relocation
101 // (:upper16: in the .s file)
102 S_LO16, // The R_ARM_MOVW_ABS_NC relocation (:lower16: in the .s file)
103
104 S_HI_8_15, // The R_ARM_THM_ALU_ABS_G3 relocation (:upper8_15: in
105 // the .s file)
106 S_HI_0_7, // The R_ARM_THM_ALU_ABS_G2_NC relocation (:upper0_8: in the
107 // .s file)
108 S_LO_8_15, // The R_ARM_THM_ALU_ABS_G1_NC relocation (:lower8_15: in
109 // the .s file)
110 S_LO_0_7, // The R_ARM_THM_ALU_ABS_G0_NC relocation (:lower0_7: in the
111 // .s file)
112
113 S_ARM_NONE,
114 S_FUNCDESC,
115 S_GOT,
116 S_GOTFUNCDESC,
117 S_GOTOFF,
118 S_GOTOFFFUNCDESC,
119 S_GOTTPOFF,
120 S_GOTTPOFF_FDPIC,
121 S_GOT_PREL,
122 S_PLT,
123 S_PREL31,
124 S_SBREL,
125 S_TARGET1,
126 S_TARGET2,
127 S_TLSCALL,
128 S_TLSDESC,
129 S_TLSDESCSEQ,
130 S_TLSGD,
131 S_TLSGD_FDPIC,
132 S_TLSLDM,
133 S_TLSLDM_FDPIC,
134 S_TLSLDO,
135 S_TPOFF,
136};
137
138const MCSpecifierExpr *createUpper16(const MCExpr *Expr, MCContext &Ctx);
139const MCSpecifierExpr *createLower16(const MCExpr *Expr, MCContext &Ctx);
140const MCSpecifierExpr *createUpper8_15(const MCExpr *Expr, MCContext &Ctx);
141const MCSpecifierExpr *createUpper0_7(const MCExpr *Expr, MCContext &Ctx);
142const MCSpecifierExpr *createLower8_15(const MCExpr *Expr, MCContext &Ctx);
143const MCSpecifierExpr *createLower0_7(const MCExpr *Expr, MCContext &Ctx);
144}
145
146} // namespace llvm
147
148#endif
149