@@ -83,13 +83,6 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
8383
8484 const FunctionDecl *fd = gd.getDecl ()->getAsFunction ();
8585
86- // If this is an alias for a lib function (e.g. __builtin_sin), emit
87- // the call using the normal call path, but using the unmangled
88- // version of the function name.
89- if (getContext ().BuiltinInfo .isLibFunction (builtinID))
90- return emitLibraryCall (*this , fd, e,
91- cgm.getBuiltinLibFunction (fd, builtinID));
92-
9386 assert (!cir::MissingFeatures::builtinCallF128 ());
9487
9588 // If the builtin has been declared explicitly with an assembler label,
@@ -124,6 +117,17 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
124117 return RValue::get (complex );
125118 }
126119
120+ case Builtin::BI__builtin_creal:
121+ case Builtin::BI__builtin_crealf:
122+ case Builtin::BI__builtin_creall:
123+ case Builtin::BIcreal:
124+ case Builtin::BIcrealf:
125+ case Builtin::BIcreall: {
126+ mlir::Value complex = emitComplexExpr (e->getArg (0 ));
127+ mlir::Value real = builder.createComplexReal (loc, complex );
128+ return RValue::get (real);
129+ }
130+
127131 case Builtin::BI__builtin_clrsb:
128132 case Builtin::BI__builtin_clrsbl:
129133 case Builtin::BI__builtin_clrsbll:
@@ -192,6 +196,13 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl &gd, unsigned builtinID,
192196 }
193197 }
194198
199+ // If this is an alias for a lib function (e.g. __builtin_sin), emit
200+ // the call using the normal call path, but using the unmangled
201+ // version of the function name.
202+ if (getContext ().BuiltinInfo .isLibFunction (builtinID))
203+ return emitLibraryCall (*this , fd, e,
204+ cgm.getBuiltinLibFunction (fd, builtinID));
205+
195206 cgm.errorNYI (e->getSourceRange (), " unimplemented builtin call" );
196207 return getUndefRValue (e->getType ());
197208}
0 commit comments