diff options
Diffstat (limited to 'clang/lib/CIR/CodeGen/CIRGenExpr.cpp')
-rw-r--r-- | clang/lib/CIR/CodeGen/CIRGenExpr.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp index fa68ad9..be94890 100644 --- a/clang/lib/CIR/CodeGen/CIRGenExpr.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenExpr.cpp @@ -1108,8 +1108,9 @@ CIRGenFunction::emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e) { return lv; } -LValue CIRGenFunction::emitStringLiteralLValue(const StringLiteral *e) { - cir::GlobalOp globalOp = cgm.getGlobalForStringLiteral(e); +LValue CIRGenFunction::emitStringLiteralLValue(const StringLiteral *e, + llvm::StringRef name) { + cir::GlobalOp globalOp = cgm.getGlobalForStringLiteral(e, name); assert(globalOp.getAlignment() && "expected alignment for string literal"); unsigned align = *(globalOp.getAlignment()); mlir::Value addr = @@ -2052,8 +2053,8 @@ mlir::Value CIRGenFunction::emitAlloca(StringRef name, mlir::Type ty, // CIR uses its own alloca address space rather than follow the target data // layout like original CodeGen. The data layout awareness should be done in // the lowering pass instead. - assert(!cir::MissingFeatures::addressSpace()); - cir::PointerType localVarPtrTy = builder.getPointerTo(ty); + cir::PointerType localVarPtrTy = + builder.getPointerTo(ty, getCIRAllocaAddressSpace()); mlir::IntegerAttr alignIntAttr = cgm.getSize(alignment); mlir::Value addr; @@ -2372,6 +2373,21 @@ mlir::Value CIRGenFunction::emitScalarConstant( return builder.getConstant(getLoc(e->getSourceRange()), constant.getValue()); } +LValue CIRGenFunction::emitPredefinedLValue(const PredefinedExpr *e) { + const StringLiteral *sl = e->getFunctionName(); + assert(sl != nullptr && "No StringLiteral name in PredefinedExpr"); + auto fn = cast<cir::FuncOp>(curFn); + StringRef fnName = fn.getName(); + fnName.consume_front("\01"); + std::array<StringRef, 2> nameItems = { + PredefinedExpr::getIdentKindName(e->getIdentKind()), fnName}; + std::string gvName = llvm::join(nameItems, "."); + if (isa_and_nonnull<BlockDecl>(curCodeDecl)) + cgm.errorNYI(e->getSourceRange(), "predefined lvalue in block"); + + return emitStringLiteralLValue(sl, gvName); +} + /// An LValue is a candidate for having its loads and stores be made atomic if /// we are operating under /volatile:ms *and* the LValue itself is volatile and /// performing such an operation can be performed without a libcall. |