LLVM  14.0.0git
M68kCallingConv.h
Go to the documentation of this file.
1 //===-- M68kCallingConv.h - M68k Custom CC 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 /// \file
10 /// This file contains the custom routines for the M68k Calling Convention
11 /// that aren't done by tablegen.
12 ///
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_LIB_TARGET_M68K_M68KCALLINGCONV_H
16 #define LLVM_LIB_TARGET_M68K_M68KCALLINGCONV_H
17 
19 
21 #include "llvm/IR/CallingConv.h"
22 #include "llvm/IR/Function.h"
23 
24 namespace llvm {
25 
26 /// Custom state to propagate llvm type info to register CC assigner
27 struct M68kCCState : public CCState {
29 
30  M68kCCState(ArrayRef<Type *> ArgTypes, CallingConv::ID CC, bool IsVarArg,
32  LLVMContext &C)
33  : CCState(CC, IsVarArg, MF, Locs, C), ArgTypeList(ArgTypes) {}
34 };
35 
36 /// NOTE this function is used to select registers for formal arguments and call
37 /// FIXME: Handling on pointer arguments is not complete
38 inline bool CC_M68k_Any_AssignToReg(unsigned &ValNo, MVT &ValVT, MVT &LocVT,
39  CCValAssign::LocInfo &LocInfo,
40  ISD::ArgFlagsTy &ArgFlags, CCState &State) {
41  const M68kCCState &CCInfo = static_cast<M68kCCState &>(State);
42 
43  static const MCPhysReg DataRegList[] = {M68k::D0, M68k::D1, M68k::A0,
44  M68k::A1};
45 
46  // Address registers have %a register priority
47  static const MCPhysReg AddrRegList[] = {
48  M68k::A0,
49  M68k::A1,
50  M68k::D0,
51  M68k::D1,
52  };
53 
54  const auto &ArgTypes = CCInfo.ArgTypeList;
55  auto I = ArgTypes.begin(), End = ArgTypes.end();
56  int No = ValNo;
57  while (No > 0 && I != End) {
58  No -= (*I)->isIntegerTy(64) ? 2 : 1;
59  ++I;
60  }
61 
62  bool IsPtr = I != End && (*I)->isPointerTy();
63 
64  unsigned Reg =
65  IsPtr ? State.AllocateReg(AddrRegList) : State.AllocateReg(DataRegList);
66 
67  if (Reg) {
68  State.addLoc(CCValAssign::getReg(ValNo, ValVT, Reg, LocVT, LocInfo));
69  return true;
70  }
71 
72  return false;
73 }
74 
75 } // namespace llvm
76 
77 #endif
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
Reg
unsigned Reg
Definition: MachineSink.cpp:1566
llvm::CCState
CCState - This class holds information needed while lowering arguments and return values.
Definition: CallingConvLower.h:191
llvm::CCState::addLoc
void addLoc(const CCValAssign &V)
Definition: CallingConvLower.h:253
llvm::M68kCCState
Custom state to propagate llvm type info to register CC assigner.
Definition: M68kCallingConv.h:27
llvm::M68kCCState::M68kCCState
M68kCCState(ArrayRef< Type * > ArgTypes, CallingConv::ID CC, bool IsVarArg, MachineFunction &MF, SmallVectorImpl< CCValAssign > &Locs, LLVMContext &C)
Definition: M68kCallingConv.h:30
llvm::InlinerFunctionImportStatsOpts::No
@ No
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
llvm::CC_M68k_Any_AssignToReg
bool CC_M68k_Any_AssignToReg(unsigned &ValNo, MVT &ValVT, MVT &LocVT, CCValAssign::LocInfo &LocInfo, ISD::ArgFlagsTy &ArgFlags, CCState &State)
NOTE this function is used to select registers for formal arguments and call FIXME: Handling on point...
Definition: M68kCallingConv.h:38
llvm::CallingConv::ID
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
llvm::CCValAssign::LocInfo
LocInfo
Definition: CallingConvLower.h:35
M68kMCTargetDesc.h
llvm::LLVMContext
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:68
I
#define I(x, y, z)
Definition: MD5.cpp:59
llvm::MVT
Machine Value Type.
Definition: MachineValueType.h:31
llvm::MachineFunction
Definition: MachineFunction.h:230
llvm::ArrayRef
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: APInt.h:32
llvm::CCState::AllocateReg
MCRegister AllocateReg(MCPhysReg Reg)
AllocateReg - Attempt to allocate one register.
Definition: CallingConvLower.h:351
llvm::ISD::ArgFlagsTy
Definition: TargetCallingConv.h:27
CallingConv.h
uint16_t
CallingConvLower.h
Function.h
llvm::CCValAssign::getReg
static CCValAssign getReg(unsigned ValNo, MVT ValVT, unsigned RegNo, MVT LocVT, LocInfo HTP)
Definition: CallingConvLower.h:79
llvm::SmallVectorImpl
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:43
llvm::M68kCCState::ArgTypeList
ArrayRef< Type * > ArgTypeList
Definition: M68kCallingConv.h:28