Skip to content

Commit bb2d810

Browse files
resistornikic
authored andcommitted
Automerge: [CHERI] Add enum values and LL parse/print support for CHERIoT calling conventions. (#156328)
This is the set of the calling conventions supported by the CHERIoT downstream of LLVM. --------- Co-authored-by: Nikita Popov <[email protected]>
2 parents 2c47298 + 6438d01 commit bb2d810

File tree

5 files changed

+34
-0
lines changed

5 files changed

+34
-0
lines changed

llvm/include/llvm/AsmParser/LLToken.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ enum Kind {
187187
kw_graalcc,
188188
kw_riscv_vector_cc,
189189
kw_riscv_vls_cc,
190+
kw_cheriot_compartmentcallcc,
191+
kw_cheriot_compartmentcalleecc,
192+
kw_cheriot_librarycallcc,
190193

191194
// Attributes:
192195
kw_attributes,

llvm/include/llvm/IR/CallingConv.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,16 @@ namespace CallingConv {
287287
// Calling convention for AMDGPU whole wave functions.
288288
AMDGPU_Gfx_WholeWave = 124,
289289

290+
/// Calling convention used for CHERIoT when crossing a protection boundary.
291+
CHERIoT_CompartmentCall = 125,
292+
/// Calling convention used for the callee of CHERIoT_CompartmentCall.
293+
/// Ignores the first two capability arguments and the first integer
294+
/// argument, zeroes all unused return registers on return.
295+
CHERIoT_CompartmentCallee = 126,
296+
/// Calling convention used for CHERIoT for cross-library calls to a
297+
/// stateless compartment.
298+
CHERIoT_LibraryCall = 127,
299+
290300
/// The highest possible ID. Must be some 2^k - 1.
291301
MaxID = 1023
292302
};

llvm/lib/AsmParser/LLLexer.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,9 @@ lltok::Kind LLLexer::LexIdentifier() {
685685
KEYWORD(graalcc);
686686
KEYWORD(riscv_vector_cc);
687687
KEYWORD(riscv_vls_cc);
688+
KEYWORD(cheriot_compartmentcallcc);
689+
KEYWORD(cheriot_compartmentcalleecc);
690+
KEYWORD(cheriot_librarycallcc);
688691

689692
KEYWORD(cc);
690693
KEYWORD(c);

llvm/lib/AsmParser/LLParser.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2315,6 +2315,15 @@ bool LLParser::parseOptionalCallingConv(unsigned &CC) {
23152315
#undef CC_VLS_CASE
23162316
}
23172317
return false;
2318+
case lltok::kw_cheriot_compartmentcallcc:
2319+
CC = CallingConv::CHERIoT_CompartmentCall;
2320+
break;
2321+
case lltok::kw_cheriot_compartmentcalleecc:
2322+
CC = CallingConv::CHERIoT_CompartmentCallee;
2323+
break;
2324+
case lltok::kw_cheriot_librarycallcc:
2325+
CC = CallingConv::CHERIoT_LibraryCall;
2326+
break;
23182327
case lltok::kw_cc: {
23192328
Lex.Lex();
23202329
return parseUInt32(CC);

llvm/lib/IR/AsmWriter.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,15 @@ static void PrintCallingConv(unsigned cc, raw_ostream &Out) {
430430
CC_VLS_CASE(32768)
431431
CC_VLS_CASE(65536)
432432
#undef CC_VLS_CASE
433+
case CallingConv::CHERIoT_CompartmentCall:
434+
Out << "cheriot_compartmentcallcc";
435+
break;
436+
case CallingConv::CHERIoT_CompartmentCallee:
437+
Out << "cheriot_compartmentcalleecc";
438+
break;
439+
case CallingConv::CHERIoT_LibraryCall:
440+
Out << "cheriot_librarycallcc";
441+
break;
433442
}
434443
}
435444

0 commit comments

Comments
 (0)