Commit b4f4e370 authored by Sam Clegg's avatar Sam Clegg
Browse files

[WebAssebmly][MC] Support .import_name/.import_field asm directives

Convert the MC test to use asm rather than bitcode.

This is a precursor to https://reviews.llvm.org/D70520.

Differential Revision: https://reviews.llvm.org/D70877
parent 1d9291cc
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -4114,7 +4114,7 @@ name, which typically identifies a module from which to import, and a field
name, which typically identifies a field from that module to import. By
default, module names for C/C++ symbols are assigned automatically by the
linker. This attribute can be used to override the default behavior, and
reuqest a specific module name be used instead.
request a specific module name be used instead.
  }];
}

@@ -4131,7 +4131,7 @@ name, which typically identifies a module from which to import, and a field
name, which typically identifies a field from that module to import. By
default, field names for C/C++ symbols are the same as their C/C++ symbol
names. This attribute can be used to override the default behavior, and
reuqest a specific field name be used instead.
request a specific field name be used instead.
  }];
}

+1 −0
Original line number Diff line number Diff line
@@ -78,6 +78,7 @@ public:
  }
  void setImportModule(StringRef Name) { ImportModule = Name; }

  bool hasImportName() const { return ImportName.hasValue(); }
  const StringRef getImportName() const {
      if (ImportName.hasValue()) {
          return ImportName.getValue();
+1 −1
Original line number Diff line number Diff line
@@ -1452,7 +1452,7 @@ uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm,
        Flags |= wasm::WASM_SYMBOL_EXPORTED;
      }
    }
    if (WS.getName() != WS.getImportName())
    if (WS.hasImportName())
      Flags |= wasm::WASM_SYMBOL_EXPLICIT_NAME;

    wasm::WasmSymbolInfo Info;
+24 −0
Original line number Diff line number Diff line
@@ -712,6 +712,30 @@ public:
      return expect(AsmToken::EndOfStatement, "EOL");
    }

    if (DirectiveID.getString() == ".import_module") {
      auto SymName = expectIdent();
      if (SymName.empty())
        return true;
      if (expect(AsmToken::Comma, ","))
        return true;
      auto ImportModule = expectIdent();
      auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
      WasmSym->setImportModule(ImportModule);
      TOut.emitImportModule(WasmSym, ImportModule);
    }

    if (DirectiveID.getString() == ".import_name") {
      auto SymName = expectIdent();
      if (SymName.empty())
        return true;
      if (expect(AsmToken::Comma, ","))
        return true;
      auto ImportName = expectIdent();
      auto WasmSym = cast<MCSymbolWasm>(Ctx.getOrCreateSymbol(SymName));
      WasmSym->setImportName(ImportName);
      TOut.emitImportName(WasmSym, ImportName);
    }

    if (DirectiveID.getString() == ".eventtype") {
      auto SymName = expectIdent();
      if (SymName.empty())
Loading