How about calling another function:
int foo() { return 0xFF; } int bar() { return foo(); }
Code snippets:
... def CC_HP41MCODE : CallingConv<[]>; ... def SDT_HP41MCODENCXQ : SDTypeProfile<0, -1, [SDTCisVT<0, iPTR>]>; def HP41MCODENCXQ : SDNode<"HP41MCODEISD::NCXQ", SDT_HP41MCODENCXQ, [SDNPHasChain, SDNPOptInGlue, SDNPOutGlue, SDNPVariadic]>; ... def calltarget : Operand; ... let isCall=1 in { def NCXQ : HP41MCODEInst<0x001, (outs), (ins calltarget:$addr), "?NC XQ $addr", [(HP41MCODENCXQ tglobaladdr:$addr)]>; } ... NCXQ, // A call instruction. ... SDValue HP41MCODETargetLowering::LowerCall( TargetLowering::CallLoweringInfo &CLI, SmallVectorImpl &InVals) const { ... CCInfo.AnalyzeCallOperands(Outs, CC_HP41MCODE); ... Chain = DAG.getNode(HP41MCODEISD::NCXQ, DL, NodeTys, Ops); ... return Chain; } ...
The following assembly is produced:
.file "hello.c" .text .globl foo ! -- Begin function foo .type foo,@function foo: ! @foo ! %bb.0: ! %entry LDI S&X HEX: 0FF RTN .Lfunc_end0: .size foo, .Lfunc_end0-foo ! -- End function .globl bar ! -- Begin function bar .type bar,@function bar: ! @bar ! %bb.0: ! %entry ?NC XQ foo RTN .Lfunc_end1: .size bar, .Lfunc_end1-bar ! -- End function .ident "clang version 20.0.0git (https://github.com/llvm/llvm-project.git ea1dfd50bfdfbd75969fd7653bc71c81f2a2350f)" .section ".note.GNU-stack" .addrsig .addrsig_sym foo