xref: /freebsd/contrib/llvm-project/llvm/lib/Target/WebAssembly/MCTargetDesc/WebAssemblyMCAsmInfo.cpp (revision 60d78908f57cf2100d5aeafa7db5d97cda3c5607)
1 //===-- WebAssemblyMCAsmInfo.cpp - WebAssembly 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 /// \file
10 /// This file contains the declarations of the WebAssemblyMCAsmInfo
11 /// properties.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #include "WebAssemblyMCAsmInfo.h"
16 #include "WebAssemblyMCTargetDesc.h"
17 #include "llvm/MC/MCExpr.h"
18 #include "llvm/TargetParser/Triple.h"
19 
20 using namespace llvm;
21 
22 #define DEBUG_TYPE "wasm-mc-asm-info"
23 
24 const MCAsmInfo::AtSpecifier atSpecifiers[] = {
25     {WebAssembly::S_TYPEINDEX, "TYPEINDEX"},
26     {WebAssembly::S_TBREL, "TBREL"},
27     {WebAssembly::S_MBREL, "MBREL"},
28     {WebAssembly::S_TLSREL, "TLSREL"},
29     {WebAssembly::S_GOT, "GOT"},
30     {WebAssembly::S_GOT_TLS, "GOT@TLS"},
31     {WebAssembly::S_FUNCINDEX, "FUNCINDEX"},
32 };
33 
34 WebAssemblyMCAsmInfo::~WebAssemblyMCAsmInfo() = default; // anchor.
35 
36 WebAssemblyMCAsmInfo::WebAssemblyMCAsmInfo(const Triple &T,
37                                            const MCTargetOptions &Options) {
38   CodePointerSize = CalleeSaveStackSlotSize = T.isArch64Bit() ? 8 : 4;
39 
40   // TODO: What should MaxInstLength be?
41 
42   UseDataRegionDirectives = true;
43 
44   // Use .skip instead of .zero because .zero is confusing when used with two
45   // arguments (it doesn't actually zero things out).
46   ZeroDirective = "\t.skip\t";
47 
48   Data8bitsDirective = "\t.int8\t";
49   Data16bitsDirective = "\t.int16\t";
50   Data32bitsDirective = "\t.int32\t";
51   Data64bitsDirective = "\t.int64\t";
52 
53   AlignmentIsInBytes = false;
54   COMMDirectiveAlignmentIsInBytes = false;
55   LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
56 
57   SupportsDebugInformation = true;
58   ExceptionsType = ExceptionHandling::None;
59 
60   initializeAtSpecifiers(atSpecifiers);
61 }
62