From 78857e7263ba555fb40b286c6b40fcd35a85a65a Mon Sep 17 00:00:00 2001 From: Sirui Mu Date: Thu, 17 Apr 2025 22:38:37 +0800 Subject: [CIR] cir.call with scalar return type (#135552) This PR introduces support for calling functions with a scalar return type to the upstream. This PR also includes an initial version of `CIRGenTargetInfo` and related definitions which are essential for the CIRGen of call ops. Related to #132487 . --- clang/lib/CIR/CodeGen/CIRGenModule.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'clang/lib/CIR/CodeGen/CIRGenModule.cpp') diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp b/clang/lib/CIR/CodeGen/CIRGenModule.cpp index ddcdc0d..1b50454 100644 --- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp +++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp @@ -129,6 +129,34 @@ CharUnits CIRGenModule::getNaturalTypeAlignment(QualType t, return alignment; } +const TargetCIRGenInfo &CIRGenModule::getTargetCIRGenInfo() { + if (theTargetCIRGenInfo) + return *theTargetCIRGenInfo; + + const llvm::Triple &triple = getTarget().getTriple(); + switch (triple.getArch()) { + default: + assert(!cir::MissingFeatures::targetCIRGenInfoArch()); + + // Currently we just fall through to x86_64. + [[fallthrough]]; + + case llvm::Triple::x86_64: { + switch (triple.getOS()) { + default: + assert(!cir::MissingFeatures::targetCIRGenInfoOS()); + + // Currently we just fall through to x86_64. + [[fallthrough]]; + + case llvm::Triple::Linux: + theTargetCIRGenInfo = createX8664TargetCIRGenInfo(genTypes); + return *theTargetCIRGenInfo; + } + } + } +} + mlir::Location CIRGenModule::getLoc(SourceLocation cLoc) { assert(cLoc.isValid() && "expected valid source location"); const SourceManager &sm = astContext.getSourceManager(); -- cgit v1.1