65816-llvm-mos/src/llvm/lib/Target/W65816/W65816CallingConv.td
2026-04-28 16:49:41 -05:00

39 lines
1.8 KiB
TableGen

//==- W65816CallingConv.td - Calling Conventions for W65816 -*- tablegen -*-==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
// This describes the calling conventions for the W65816 architecture.
//
// The 65816 standard C calling convention passes parameters on the stack and
// returns values in the accumulator. Tool-call and interrupt ABIs will be
// added in a later change; only the skeleton is defined here.
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
// W65816 Return Value Calling Convention
//===----------------------------------------------------------------------===//
def RetCC_W65816 : CallingConv<[
// i8 values are returned in the 8-bit accumulator.
CCIfType<[i8], CCAssignToReg<[A]>>,
// i16 values are returned in A; for a split i32 (legalizer produces
// two i16 returns), the second slot lands in X. LowerReturn /
// LowerCall hardcode the same A,X order — keep them in sync.
CCIfType<[i16], CCAssignToReg<[A, X]>>
]>;
//===----------------------------------------------------------------------===//
// W65816 Argument Calling Convention
//===----------------------------------------------------------------------===//
def CC_W65816 : CallingConv<[
// Pass byval aggregates on the stack.
CCIfByVal<CCPassByVal<2, 1>>,
// Promote i8 arguments to i16 when passed on the stack.
CCIfType<[i8], CCPromoteToType<i16>>,
// Integer arguments occupy 2-byte stack slots with 1-byte alignment.
CCIfType<[i16], CCAssignToStack<2, 1>>
]>;