================
@@ -263,8 +263,14 @@ class ScalarExprEmitter : public
StmtVisitor<ScalarExprEmitter, mlir::Value> {
return {};
}
mlir::Value VisitEmbedExpr(EmbedExpr *e) {
- cgf.cgm.errorNYI(e->getSourceRange(), "ScalarExprEmitter: embed");
- return {};
+ assert(e->getDataElementCount() == 1);
+ auto it = e->begin();
+ QualType qualTy = e->getType();
+ mlir::Type ty = cgf.convertType(qualTy);
+ llvm::APInt value = (*it)->getValue();
+ uint64_t actualValue = qualTy->isSignedIntegerType() ? value.getSExtValue()
+ :
value.getZExtValue();
+ return builder.getConstInt(cgf.getLoc(e->getExprLoc()), ty, actualValue);
----------------
AmrDeveloper wrote:
Identically, we should use `getConstInt` and pass the APInt, but in our
builder, when we pass APInt, we just construct APSInt with `unsigned = true`,
so maybe we should add another parameter to this helper to control singing
https://github.com/llvm/llvm-project/blob/333ee931df888c7e0c62249290b20c17cb33d10b/clang/lib/CIR/CodeGen/CIRGenBuilder.cpp#L55-L58
https://github.com/llvm/llvm-project/pull/172088
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits