LLVM 19.0.0git
CSKYCallingConv.h
Go to the documentation of this file.
1//=== CSKYCallingConv.h - CSKY Custom Calling Convention Routines -*-C++-*-===//
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// This file contains the custom routines for the CSKY Calling Convention that
10// aren't done by tablegen.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_LIB_TARGET_CSKY_CSKYCALLINGCONV_H
15#define LLVM_LIB_TARGET_CSKY_CSKYCALLINGCONV_H
16
17#include "CSKY.h"
18#include "CSKYSubtarget.h"
21#include "llvm/IR/CallingConv.h"
22
23namespace llvm {
24
25static bool CC_CSKY_ABIV2_SOFT_64(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
26 CCValAssign::LocInfo &LocInfo,
27 ISD::ArgFlagsTy &ArgFlags, CCState &State) {
28
29 static const MCPhysReg ArgGPRs[] = {CSKY::R0, CSKY::R1, CSKY::R2, CSKY::R3};
31 LocVT = MVT::i32;
32 if (!Reg) {
33 unsigned StackOffset = State.AllocateStack(8, Align(4));
34 State.addLoc(
35 CCValAssign::getMem(ValNo, ValVT, StackOffset, LocVT, LocInfo));
36 return true;
37 }
38 if (!State.AllocateReg(ArgGPRs))
39 State.AllocateStack(4, Align(4));
40 State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
41 return true;
42}
43
44static bool Ret_CSKY_ABIV2_SOFT_64(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
45 CCValAssign::LocInfo &LocInfo,
46 ISD::ArgFlagsTy &ArgFlags, CCState &State) {
47
48 static const MCPhysReg ArgGPRs[] = {CSKY::R0, CSKY::R1};
50 LocVT = MVT::i32;
51 if (!Reg)
52 return false;
53
54 if (!State.AllocateReg(ArgGPRs))
55 return false;
56
57 State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
58 return true;
59}
60
61} // namespace llvm
62
63#endif
const MCPhysReg ArgGPRs[]
unsigned Reg
CCState - This class holds information needed while lowering arguments and return values.
MCRegister AllocateReg(MCPhysReg Reg)
AllocateReg - Attempt to allocate one register.
int64_t AllocateStack(unsigned Size, Align Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
void addLoc(const CCValAssign &V)
static CCValAssign getMem(unsigned ValNo, MVT ValVT, int64_t Offset, MVT LocVT, LocInfo HTP, bool IsCustom=false)
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP, bool IsCustom=false)
Machine Value Type.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
StackOffset holds a fixed and a scalable offset in bytes.
Definition: TypeSize.h:33
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
static bool Ret_CSKY_ABIV2_SOFT_64(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
static bool CC_CSKY_ABIV2_SOFT_64(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39