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
20using namespace llvm;
21
22#define DEBUG_TYPE "wasm-mc-asm-info"
23
24const MCAsmInfo::AtSpecifier atSpecifiers[] = {
25 {.Kind: WebAssembly::S_TYPEINDEX, .Name: "TYPEINDEX"},
26 {.Kind: WebAssembly::S_TBREL, .Name: "TBREL"},
27 {.Kind: WebAssembly::S_MBREL, .Name: "MBREL"},
28 {.Kind: WebAssembly::S_TLSREL, .Name: "TLSREL"},
29 {.Kind: WebAssembly::S_GOT, .Name: "GOT"},
30 {.Kind: WebAssembly::S_GOT_TLS, .Name: "GOT@TLS"},
31 {.Kind: WebAssembly::S_FUNCINDEX, .Name: "FUNCINDEX"},
32};
33
34WebAssemblyMCAsmInfo::~WebAssemblyMCAsmInfo() = default; // anchor.
35
36WebAssemblyMCAsmInfo::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
59 // When compilation is done on a cpp file by clang, the exception model info
60 // is stored in LangOptions, which is later used to set the info in
61 // TargetOptions and then MCAsmInfo in CodeGenTargetMachine::initAsmInfo().
62 // But this process does not happen when compiling bitcode directly with
63 // clang, so we make sure this info is set correctly.
64 if (WebAssembly::WasmEnableEH || WebAssembly::WasmEnableSjLj)
65 ExceptionsType = ExceptionHandling::Wasm;
66
67 initializeAtSpecifiers(atSpecifiers);
68}
69