blob: b045fcb81847225023c3b4d671e7ac56df0614c5 [file] [log] [blame]
Chris Lattnerdc3adc82007-02-27 04:43:02 +00001//===-- llvm/CallingConvLower.cpp - Calling Conventions -------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by Chris Lattner and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the CCState class, used for lowering and implementing
11// calling conventions.
12//
13//===----------------------------------------------------------------------===//
14
15#include "llvm/CodeGen/CallingConvLower.h"
16#include "llvm/Target/MRegisterInfo.h"
Chris Lattner9f0591942007-02-27 05:13:54 +000017#include "llvm/Target/TargetMachine.h"
Chris Lattnerdc3adc82007-02-27 04:43:02 +000018using namespace llvm;
19
Chris Lattner9f0591942007-02-27 05:13:54 +000020CCState::CCState(unsigned CC, const TargetMachine &tm,
21 SmallVector<CCValAssign, 16> &locs)
22 : CallingConv(CC), TM(tm), MRI(*TM.getRegisterInfo()), Locs(locs) {
Chris Lattnerdc3adc82007-02-27 04:43:02 +000023 // No stack is used.
24 StackOffset = 0;
25
26 UsedRegs.resize(MRI.getNumRegs());
27}
28
29
30/// MarkAllocated - Mark a register and all of its aliases as allocated.
31void CCState::MarkAllocated(unsigned Reg) {
32 UsedRegs[Reg/32] |= 1 << (Reg&31);
33
34 if (const unsigned *RegAliases = MRI.getAliasSet(Reg))
35 for (; (Reg = *RegAliases); ++RegAliases)
36 UsedRegs[Reg/32] |= 1 << (Reg&31);
37}