LLVM  15.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 
23 namespace llvm {
24 
25 static 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 
44 static 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
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::CCState
CCState - This class holds information needed while lowering arguments and return values.
Definition: CallingConvLower.h:189
llvm::CCState::addLoc
void addLoc(const CCValAssign &V)
Definition: CallingConvLower.h:251
llvm::X86Disassembler::Reg
Reg
All possible values of the reg field in the ModR/M byte.
Definition: X86DisassemblerDecoder.h:462
CSKY.h
TargetInstrInfo.h
R2
#define R2(n)
CSKYSubtarget.h
llvm::CC_CSKY_ABIV2_SOFT_64
static bool CC_CSKY_ABIV2_SOFT_64(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
Definition: CSKYCallingConv.h:25
Align
uint64_t Align
Definition: ELFObjHandler.cpp:81
llvm::CCValAssign::LocInfo
LocInfo
Definition: CallingConvLower.h:33
llvm::CCValAssign::getMem
static CCValAssign getMem(unsigned ValNo, MVT ValVT, unsigned Offset, MVT LocVT, LocInfo HTP)
Definition: CallingConvLower.h:100
llvm::Ret_CSKY_ABIV2_SOFT_64
static bool Ret_CSKY_ABIV2_SOFT_64(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
Definition: CSKYCallingConv.h:44
llvm::MVT
Machine Value Type.
Definition: MachineValueType.h:31
llvm::CCState::AllocateReg
MCRegister AllocateReg(MCPhysReg Reg)
AllocateReg - Attempt to allocate one register.
Definition: CallingConvLower.h:349
llvm::StackOffset
StackOffset is a class to represent an offset with 2 dimensions, named fixed and scalable,...
Definition: TypeSize.h:134
llvm::ISD::ArgFlagsTy
Definition: TargetCallingConv.h:27
llvm::Register
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
CallingConv.h
uint16_t
CallingConvLower.h
llvm::CCState::AllocateStack
unsigned AllocateStack(unsigned Size, Align Alignment)
AllocateStack - Allocate a chunk of stack space with the specified size and alignment.
Definition: CallingConvLower.h:423
llvm::MVT::i32
@ i32
Definition: MachineValueType.h:46
llvm::CCValAssign::getReg
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
Definition: CallingConvLower.h:77
ArgGPRs
static const MCPhysReg ArgGPRs[]
Definition: LoongArchISelLowering.cpp:68