| 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/ADT/Enum.h" |
| 18 | #include "llvm/MC/MCExpr.h" |
| 19 | #include "llvm/TargetParser/Triple.h" |
| 20 | |
| 21 | using namespace llvm; |
| 22 | |
| 23 | #define DEBUG_TYPE "wasm-mc-asm-info" |
| 24 | |
| 25 | constexpr EnumStringDef<MCAsmInfo::AtSpecifierKind> AtSpecifierDefs[] = { |
| 26 | {.Names: {"TYPEINDEX" }, .Value: WebAssembly::S_TYPEINDEX}, |
| 27 | {.Names: {"TBREL" }, .Value: WebAssembly::S_TBREL}, |
| 28 | {.Names: {"MBREL" }, .Value: WebAssembly::S_MBREL}, |
| 29 | {.Names: {"TLSREL" }, .Value: WebAssembly::S_TLSREL}, |
| 30 | {.Names: {"GOT" }, .Value: WebAssembly::S_GOT}, |
| 31 | {.Names: {"GOT@TLS" }, .Value: WebAssembly::S_GOT_TLS}, |
| 32 | {.Names: {"FUNCINDEX" }, .Value: WebAssembly::S_FUNCINDEX}, |
| 33 | }; |
| 34 | constexpr auto atSpecifiers = BUILD_ENUM_STRINGS(AtSpecifierDefs); |
| 35 | |
| 36 | WebAssemblyMCAsmInfo::~WebAssemblyMCAsmInfo() = default; // anchor. |
| 37 | |
| 38 | WebAssemblyMCAsmInfo::WebAssemblyMCAsmInfo(const Triple &T, |
| 39 | const MCTargetOptions &Options) |
| 40 | : MCAsmInfoWasm(Options) { |
| 41 | CodePointerSize = CalleeSaveStackSlotSize = T.isArch64Bit() ? 8 : 4; |
| 42 | |
| 43 | // TODO: What should MaxInstLength be? |
| 44 | |
| 45 | UseDataRegionDirectives = true; |
| 46 | |
| 47 | // Use .skip instead of .zero because .zero is confusing when used with two |
| 48 | // arguments (it doesn't actually zero things out). |
| 49 | ZeroDirective = "\t.skip\t" ; |
| 50 | |
| 51 | Data8bitsDirective = "\t.int8\t" ; |
| 52 | Data16bitsDirective = "\t.int16\t" ; |
| 53 | Data32bitsDirective = "\t.int32\t" ; |
| 54 | Data64bitsDirective = "\t.int64\t" ; |
| 55 | |
| 56 | AlignmentIsInBytes = false; |
| 57 | COMMDirectiveAlignmentIsInBytes = false; |
| 58 | LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment; |
| 59 | |
| 60 | SupportsDebugInformation = true; |
| 61 | ExceptionsType = ExceptionHandling::None; |
| 62 | |
| 63 | initializeAtSpecifiers(atSpecifiers); |
| 64 | } |
| 65 | |