Skip to content

Commit 6ced662

Browse files
JinkelaLFsWang
authored andcommitted
[CodeGen] Cancel attaching '.metadata' to wasm bytecode.
1 parent dd539e0 commit 6ced662

File tree

5 files changed

+25
-0
lines changed

5 files changed

+25
-0
lines changed

include/soll/Basic/DiagnosticParseKinds.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ DIAG(err_multiple_fallbacks, CLASS_ERROR, (unsigned)diag::Severity::Error, "mult
3333
DIAG(warn_virtual_already_specified, CLASS_WARNING, (unsigned)diag::Severity::Warning, "Virtual already specified.", 0, false, 1)
3434
DIAG(warn_override_already_specified, CLASS_WARNING, (unsigned)diag::Severity::Warning, "Override already specified.", 0, false, 1)
3535
DIAG(err_multiinherited_unsupport, CLASS_ERROR, (unsigned)diag::Severity::Error, "Multinherited overrided is not supported!", 0, false, 1)
36+
DIAG(warn_yul_metadata, CLASS_WARNING, (unsigned)diag::Severity::Warning, "soll currently does not attach '.metadata' to wasm bytecode.", 0, false, 1)

include/soll/Basic/DiagnosticSemaKinds.inc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ DIAG(err_visibility_not_match, CLASS_ERROR, (unsigned)diag::Severity::Error, "vi
3333
DIAG(err_private_function_can_not_be_virtual, CLASS_ERROR, (unsigned)diag::Severity::Error, "private funtcion %0 can not be virtual", 0, false, 1)
3434
DIAG(err_mutability_overriding_not_allow, CLASS_ERROR, (unsigned)diag::Severity::Error, "can not change function %0 mutability", 0, false, 1)
3535
DIAG(err_func_to_var_overrided_unsoupport, CLASS_ERROR, (unsigned)diag::Severity::Error, "function to state variables override is unsupport", 0, false, 1)
36+
DIAG(err_yul_access_special_object, CLASS_ERROR, (unsigned)diag::Severity::Error, "'%0' can not be access by 'datasize', 'dataoffset' or 'datacopy'.", 0, false, 1)

lib/CodeGen/CodeGenModule.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,6 +1618,10 @@ void CodeGenModule::emitYulObject(const YulObject *YO) {
16181618
*/
16191619
}
16201620
assert(nullptr != YO->getCode());
1621+
if (YO->getName() == ".metadata") {
1622+
// TODO: attach '.metadata' to wasm bytecode.
1623+
return;
1624+
}
16211625
for (const auto *O : YO->getObjectList()) {
16221626
emitYulObject(O);
16231627
getEntry().clear();

lib/Parse/ParseYul.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
2+
#include "soll/Basic/DiagnosticIDs.h"
3+
#include "soll/Basic/DiagnosticParse.h"
24
#include "soll/Parse/Parser.h"
35

46
using namespace std;
@@ -51,6 +53,9 @@ unique_ptr<YulObject> Parser::parseYulObject() {
5153
ConsumeToken();
5254

5355
auto Name = stringUnquote(std::string(Tok.getLiteralData(), Tok.getLength()));
56+
if (Name == ".metadata") {
57+
Diag(diag::warn_yul_metadata);
58+
}
5459

5560
ConsumeStringToken();
5661
ExpectAndConsume(tok::l_brace);

lib/Sema/SemaExprAsm.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
22
#include "soll/AST/AST.h"
3+
#include "soll/Basic/DiagnosticSema.h"
34
#include "soll/Sema/Sema.h"
45

56
namespace soll {
@@ -674,6 +675,19 @@ Sema::CreateAsmBuiltinCallExpr(SourceRange L, const AsmIdentifier &Callee,
674675
return std::make_unique<AsmBinaryOperator>(L, std::move(Args[1]),
675676
std::move(Args[0]),
676677
std::move(ReturnTy), BO_AShr);
678+
case AsmIdentifier::SpecialIdentifier::dataoffset:
679+
case AsmIdentifier::SpecialIdentifier::datasize: {
680+
if (auto *ICE = dynamic_cast<const ImplicitCastExpr *>(Args[0].get())) {
681+
if (auto *SL = dynamic_cast<const StringLiteral *>(ICE->getSubExpr())) {
682+
std::string Name = SL->getValue();
683+
if (Name.size() && Name[0] == '.') {
684+
Diag(L.getBegin(), diag::err_yul_access_special_object) << Name;
685+
assert(false);
686+
}
687+
}
688+
}
689+
[[fallthrough]];
690+
}
677691
default: ///< treated as normal CallExpr
678692
break;
679693
}

0 commit comments

Comments
 (0)