WebAssemblyMCAsmInfo.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. #include "WebAssemblyMCAsmInfo.h"
  15. #include "Utils/WebAssemblyUtilities.h"
  16. #include "llvm/ADT/Triple.h"
  17. using namespace llvm;
  18. #define DEBUG_TYPE "wasm-mc-asm-info"
  19. WebAssemblyMCAsmInfo::~WebAssemblyMCAsmInfo() = default; // anchor.
  20. WebAssemblyMCAsmInfo::WebAssemblyMCAsmInfo(const Triple &T,
  21. const MCTargetOptions &Options) {
  22. CodePointerSize = CalleeSaveStackSlotSize = T.isArch64Bit() ? 8 : 4;
  23. // TODO: What should MaxInstLength be?
  24. UseDataRegionDirectives = true;
  25. // Use .skip instead of .zero because .zero is confusing when used with two
  26. // arguments (it doesn't actually zero things out).
  27. ZeroDirective = "\t.skip\t";
  28. Data8bitsDirective = "\t.int8\t";
  29. Data16bitsDirective = "\t.int16\t";
  30. Data32bitsDirective = "\t.int32\t";
  31. Data64bitsDirective = "\t.int64\t";
  32. AlignmentIsInBytes = false;
  33. COMMDirectiveAlignmentIsInBytes = false;
  34. LCOMMDirectiveAlignmentType = LCOMM::Log2Alignment;
  35. SupportsDebugInformation = true;
  36. // When compilation is done on a cpp file by clang, the exception model info
  37. // is stored in LangOptions, which is later used to set the info in
  38. // TargetOptions and then MCAsmInfo in LLVMTargetMachine::initAsmInfo(). But
  39. // this process does not happen when compiling bitcode directly with clang, so
  40. // we make sure this info is set correctly.
  41. if (WebAssembly::WasmEnableEH || WebAssembly::WasmEnableSjLj)
  42. ExceptionsType = ExceptionHandling::Wasm;
  43. }