1//===-- M68kCallingConv.td - Calling Conventions for M68k --*- tablegen -*-===// 2// 3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4// See https://llvm.org/LICENSE.txt for license information. 5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6// 7//===----------------------------------------------------------------------===// 8/// 9/// \file 10/// This describes the calling conventions for the M68k architectures. These 11/// conventions assume Int to be 4 bytes and 4 byte aligned. 12/// 13//===----------------------------------------------------------------------===// 14 15// TODO Verify C convention follows SysV M68K ABI 16 17class CCIfSubtarget<string F, CCAction A> 18 : CCIf<!strconcat("static_cast<const M68kSubtarget &>" 19 "(State.getMachineFunction().getSubtarget()).", F), A>; 20 21//===----------------------------------------------------------------------===// 22// Return Value Calling Conventions 23//===----------------------------------------------------------------------===// 24 25/// M68k C return convention. 26def RetCC_M68k_C : CallingConv<[ 27 CCIfPtr<CCAssignToReg<[A0]>>, 28 CCIfType<[i1], CCPromoteToType<i8>>, 29 CCIfType<[i8], CCAssignToReg<[BD0, BD1]>>, 30 CCIfType<[i16], CCAssignToReg<[WD0, WD1]>>, 31 CCIfType<[i32], CCAssignToReg<[D0, D1]>>, 32]>; 33 34/// M68k fastcc return convention. 35/// This convention allows to return up to 16 bytes in registers which can be 36/// split among 16 1-byte values or used for a single 16-byte value. 37/// TODO: Verify its functionality and write tests 38def RetCC_M68k_Fast : CallingConv<[ 39 CCIfPtr<CCAssignToReg<[A0]>>, 40 CCIfType<[i1], CCPromoteToType<i8>>, 41 CCIfType<[i8], CCAssignToReg<[BD0, BD1]>>, 42 CCIfType<[i16], CCAssignToReg<[WD0, WD1, WA0, WA1]>>, 43 CCIfType<[i32], CCAssignToReg<[D0, D1, A0, A1]>>, 44]>; 45 46/// This is the root return-value convention for the M68k backend. 47def RetCC_M68k : CallingConv<[ 48 CCIfCC<"CallingConv::Fast", CCDelegateTo<RetCC_M68k_Fast>>, 49 CCDelegateTo<RetCC_M68k_C> 50]>; 51 52//===----------------------------------------------------------------------===// 53// M68k C Calling Convention 54//===----------------------------------------------------------------------===// 55 56/// CC_M68k_Common - In all M68k calling conventions, extra integers and FP 57/// values are spilled on the stack. 58def CC_M68k_Common : CallingConv<[ 59 /// Handles byval parameters. 60 CCIfByVal<CCPassByVal<4, 4>>, 61 62 /// Integer values get stored in stack slots that are 4 bytes in 63 /// size and 4-byte aligned. 64 CCIfType<[i32], CCAssignToStack<4, 4>> 65]>; 66 67def CC_M68k_Fast : CallingConv<[ 68 /// Promote i1/i8/i16 arguments to i32. 69 CCIfType<[i1, i8, i16], CCPromoteToType<i32>>, 70 71 /// The 'nest' parameter, if any, is passed in A1. 72 CCIfNest<CCAssignToReg<[A1]>>, // FIXME verify if this is correct 73 74 /// Since M68k uses %An for pointers and we want them be passed in regs 75 /// too we have to use custom function. 76 CCIfType<[i32], CCCustom<"CC_M68k_Any_AssignToReg">>, 77 78 /// Otherwise, same as everything else. 79 CCDelegateTo<CC_M68k_Common> 80]>; 81 82def CC_M68k_C : CallingConv<[ 83 /// Promote i1/i8/i16 arguments to i32. 84 CCIfType<[i1, i8, i16], CCPromoteToType<i32>>, 85 86 /// The 'nest' parameter, if any, is passed in A1. 87 CCIfNest<CCAssignToReg<[A1]>>, // FIXME verify if this is correct 88 89 /// Use registers only if 'inreg' used and the call is not vararg 90 CCIfNotVarArg<CCIfInReg<CCIfType<[i32], CCAssignToReg<[D0, D1]>>>>, 91 92 // TODO: Support for 'sret' 93 94 /// Otherwise, same as everything else. 95 CCDelegateTo<CC_M68k_Common> 96]>; 97 98/// This is the root argument convention for the M68k backend. 99def CC_M68k : CallingConv<[ 100 CCIfCC<"CallingConv::Fast", CCDelegateTo<CC_M68k_Fast>>, 101 CCDelegateTo<CC_M68k_C> 102]>; 103 104//===----------------------------------------------------------------------===// 105// Callee-saved Registers. 106//===----------------------------------------------------------------------===// 107 108def CSR_NoRegs : CalleeSavedRegs<(add)>; 109 110// A5 - BP 111// A6 - FP 112def CSR_STD : CalleeSavedRegs<(add D2, D3, D4, D5, D6, D7, 113 A2, A3, A4, A5, A6)>; 114 115