blob: 6f3f4582053f2c113d75c2dbbd0ba7baf1f1e315 [file] [log] [blame]
Chris Lattner035dfbe2002-08-09 20:08:06 +00001//===-- SparcInstrInfo.cpp ------------------------------------------------===//
2//
3//===----------------------------------------------------------------------===//
Vikram S. Adve30764b82001-10-18 00:01:48 +00004
5#include "SparcInternals.h"
6#include "SparcInstrSelectionSupport.h"
Vikram S. Adve30764b82001-10-18 00:01:48 +00007#include "llvm/CodeGen/InstrSelection.h"
8#include "llvm/CodeGen/InstrSelectionSupport.h"
Misha Brukmanfce11432002-10-28 00:28:31 +00009#include "llvm/CodeGen/MachineFunction.h"
Chris Lattner2ef9a6a2002-12-28 20:18:21 +000010#include "llvm/CodeGen/MachineFunctionInfo.h"
Vikram S. Adve242a8082002-05-19 15:25:51 +000011#include "llvm/CodeGen/MachineCodeForInstruction.h"
Chris Lattnere5b1ed92003-01-15 00:03:28 +000012#include "llvm/CodeGen/MachineInstrBuilder.h"
Chris Lattner2fbfdcf2002-04-07 20:49:59 +000013#include "llvm/Function.h"
Chris Lattner31bcdb82002-04-28 19:55:58 +000014#include "llvm/Constants.h"
Vikram S. Adveb9c38632001-11-08 04:57:53 +000015#include "llvm/DerivedTypes.h"
Vikram S. Adve49001162002-09-16 15:56:01 +000016#include <stdlib.h>
Vikram S. Adve30764b82001-10-18 00:01:48 +000017
Vikram S. Adve53fd4002002-07-10 21:39:50 +000018static const uint32_t MAXLO = (1 << 10) - 1; // set bits set by %lo(*)
19static const uint32_t MAXSIMM = (1 << 12) - 1; // set bits in simm13 field of OR
20
21
Chris Lattner795ba6c2003-01-15 21:36:50 +000022//---------------------------------------------------------------------------
23// Function GetConstantValueAsUnsignedInt
24// Function GetConstantValueAsSignedInt
25//
26// Convenience functions to get the value of an integral constant, for an
27// appropriate integer or non-integer type that can be held in a signed
28// or unsigned integer respectively. The type of the argument must be
29// the following:
30// Signed or unsigned integer
31// Boolean
32// Pointer
33//
34// isValidConstant is set to true if a valid constant was found.
35//---------------------------------------------------------------------------
36
37static uint64_t
38GetConstantValueAsUnsignedInt(const Value *V,
39 bool &isValidConstant)
40{
41 isValidConstant = true;
42
43 if (isa<Constant>(V))
44 if (const ConstantBool *CB = dyn_cast<ConstantBool>(V))
45 return (int64_t)CB->getValue();
46 else if (const ConstantSInt *CS = dyn_cast<ConstantSInt>(V))
47 return (uint64_t)CS->getValue();
48 else if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
49 return CU->getValue();
50
51 isValidConstant = false;
52 return 0;
53}
54
55int64_t
56GetConstantValueAsSignedInt(const Value *V, bool &isValidConstant)
57{
58 uint64_t C = GetConstantValueAsUnsignedInt(V, isValidConstant);
59 if (isValidConstant) {
60 if (V->getType()->isSigned() || C < INT64_MAX) // safe to cast to signed
61 return (int64_t) C;
62 else
63 isValidConstant = false;
64 }
65 return 0;
66}
67
68
Vikram S. Adve6c0c3012002-08-13 18:04:08 +000069//----------------------------------------------------------------------------
70// Function: CreateSETUWConst
Vikram S. Adve53fd4002002-07-10 21:39:50 +000071//
Vikram S. Adve6c0c3012002-08-13 18:04:08 +000072// Set a 32-bit unsigned constant in the register `dest', using
73// SETHI, OR in the worst case. This function correctly emulates
74// the SETUW pseudo-op for SPARC v9 (if argument isSigned == false).
75//
76// The isSigned=true case is used to implement SETSW without duplicating code.
77//
78// Optimize some common cases:
79// (1) Small value that fits in simm13 field of OR: don't need SETHI.
80// (2) isSigned = true and C is a small negative signed value, i.e.,
81// high bits are 1, and the remaining bits fit in simm13(OR).
82//----------------------------------------------------------------------------
83
Vikram S. Adve53fd4002002-07-10 21:39:50 +000084static inline void
85CreateSETUWConst(const TargetMachine& target, uint32_t C,
Misha Brukmana98cd452003-05-20 20:32:24 +000086 Instruction* dest, std::vector<MachineInstr*>& mvec,
Vikram S. Adve6c0c3012002-08-13 18:04:08 +000087 bool isSigned = false)
Vikram S. Adve53fd4002002-07-10 21:39:50 +000088{
89 MachineInstr *miSETHI = NULL, *miOR = NULL;
Vikram S. Adve6c0c3012002-08-13 18:04:08 +000090
Vikram S. Adve53fd4002002-07-10 21:39:50 +000091 // In order to get efficient code, we should not generate the SETHI if
92 // all high bits are 1 (i.e., this is a small signed value that fits in
93 // the simm13 field of OR). So we check for and handle that case specially.
94 // NOTE: The value C = 0x80000000 is bad: sC < 0 *and* -sC < 0.
95 // In fact, sC == -sC, so we have to check for this explicitly.
96 int32_t sC = (int32_t) C;
Vikram S. Adve6c0c3012002-08-13 18:04:08 +000097 bool smallNegValue =isSigned && sC < 0 && sC != -sC && -sC < (int32_t)MAXSIMM;
98
Vikram S. Adve53fd4002002-07-10 21:39:50 +000099 // Set the high 22 bits in dest if non-zero and simm13 field of OR not enough
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000100 if (!smallNegValue && (C & ~MAXLO) && C > MAXSIMM)
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000101 {
Misha Brukmana98cd452003-05-20 20:32:24 +0000102 miSETHI = BuildMI(V9::SETHI, 2).addZImm(C).addRegDef(dest);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000103 miSETHI->setOperandHi32(0);
104 mvec.push_back(miSETHI);
105 }
106
107 // Set the low 10 or 12 bits in dest. This is necessary if no SETHI
108 // was generated, or if the low 10 bits are non-zero.
109 if (miSETHI==NULL || C & MAXLO)
110 {
111 if (miSETHI)
112 { // unsigned value with high-order bits set using SETHI
Misha Brukmana98cd452003-05-20 20:32:24 +0000113 miOR = BuildMI(V9::OR,3).addReg(dest).addZImm(C).addRegDef(dest);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000114 miOR->setOperandLo32(1);
115 }
116 else
117 { // unsigned or small signed value that fits in simm13 field of OR
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000118 assert(smallNegValue || (C & ~MAXSIMM) == 0);
Misha Brukmana98cd452003-05-20 20:32:24 +0000119 miOR = BuildMI(V9::OR, 3).addMReg(target.getRegInfo()
120 .getZeroRegNum())
121 .addSImm(sC).addRegDef(dest);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000122 }
123 mvec.push_back(miOR);
124 }
125
126 assert((miSETHI || miOR) && "Oops, no code was generated!");
127}
128
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000129
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000130//----------------------------------------------------------------------------
131// Function: CreateSETSWConst
132//
133// Set a 32-bit signed constant in the register `dest', with sign-extension
134// to 64 bits. This uses SETHI, OR, SRA in the worst case.
135// This function correctly emulates the SETSW pseudo-op for SPARC v9.
136//
137// Optimize the same cases as SETUWConst, plus:
138// (1) SRA is not needed for positive or small negative values.
139//----------------------------------------------------------------------------
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000140
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000141static inline void
142CreateSETSWConst(const TargetMachine& target, int32_t C,
Misha Brukmana98cd452003-05-20 20:32:24 +0000143 Instruction* dest, std::vector<MachineInstr*>& mvec)
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000144{
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000145 // Set the low 32 bits of dest
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000146 CreateSETUWConst(target, (uint32_t) C, dest, mvec, /*isSigned*/true);
147
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000148 // Sign-extend to the high 32 bits if needed
149 if (C < 0 && (-C) > (int32_t) MAXSIMM)
Misha Brukmana98cd452003-05-20 20:32:24 +0000150 mvec.push_back(BuildMI(V9::SRA, 3).addReg(dest).addZImm(0).addRegDef(dest));
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000151}
152
153
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000154//----------------------------------------------------------------------------
155// Function: CreateSETXConst
156//
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000157// Set a 64-bit signed or unsigned constant in the register `dest'.
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000158// Use SETUWConst for each 32 bit word, plus a left-shift-by-32 in between.
159// This function correctly emulates the SETX pseudo-op for SPARC v9.
160//
161// Optimize the same cases as SETUWConst for each 32 bit word.
162//----------------------------------------------------------------------------
163
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000164static inline void
165CreateSETXConst(const TargetMachine& target, uint64_t C,
166 Instruction* tmpReg, Instruction* dest,
Misha Brukmana98cd452003-05-20 20:32:24 +0000167 std::vector<MachineInstr*>& mvec)
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000168{
169 assert(C > (unsigned int) ~0 && "Use SETUW/SETSW for 32-bit values!");
170
171 MachineInstr* MI;
172
173 // Code to set the upper 32 bits of the value in register `tmpReg'
174 CreateSETUWConst(target, (C >> 32), tmpReg, mvec);
175
176 // Shift tmpReg left by 32 bits
Misha Brukmana98cd452003-05-20 20:32:24 +0000177 mvec.push_back(BuildMI(V9::SLLX, 3).addReg(tmpReg).addZImm(32)
178 .addRegDef(tmpReg));
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000179
180 // Code to set the low 32 bits of the value in register `dest'
181 CreateSETUWConst(target, C, dest, mvec);
182
183 // dest = OR(tmpReg, dest)
Misha Brukmana98cd452003-05-20 20:32:24 +0000184 mvec.push_back(BuildMI(V9::OR,3).addReg(dest).addReg(tmpReg).addRegDef(dest));
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000185}
186
187
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000188//----------------------------------------------------------------------------
189// Function: CreateSETUWLabel
190//
191// Set a 32-bit constant (given by a symbolic label) in the register `dest'.
192//----------------------------------------------------------------------------
193
194static inline void
195CreateSETUWLabel(const TargetMachine& target, Value* val,
Misha Brukmana98cd452003-05-20 20:32:24 +0000196 Instruction* dest, std::vector<MachineInstr*>& mvec)
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000197{
198 MachineInstr* MI;
199
200 // Set the high 22 bits in dest
Misha Brukmana98cd452003-05-20 20:32:24 +0000201 MI = BuildMI(V9::SETHI, 2).addReg(val).addRegDef(dest);
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000202 MI->setOperandHi32(0);
203 mvec.push_back(MI);
204
205 // Set the low 10 bits in dest
Misha Brukmana98cd452003-05-20 20:32:24 +0000206 MI = BuildMI(V9::OR, 3).addReg(dest).addReg(val).addRegDef(dest);
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000207 MI->setOperandLo32(1);
208 mvec.push_back(MI);
209}
210
211
212//----------------------------------------------------------------------------
213// Function: CreateSETXLabel
214//
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000215// Set a 64-bit constant (given by a symbolic label) in the register `dest'.
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000216//----------------------------------------------------------------------------
217
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000218static inline void
219CreateSETXLabel(const TargetMachine& target,
220 Value* val, Instruction* tmpReg, Instruction* dest,
Misha Brukmana98cd452003-05-20 20:32:24 +0000221 std::vector<MachineInstr*>& mvec)
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000222{
223 assert(isa<Constant>(val) || isa<GlobalValue>(val) &&
224 "I only know about constant values and global addresses");
225
226 MachineInstr* MI;
227
Misha Brukmana98cd452003-05-20 20:32:24 +0000228 MI = BuildMI(V9::SETHI, 2).addPCDisp(val).addRegDef(tmpReg);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000229 MI->setOperandHi64(0);
230 mvec.push_back(MI);
231
Misha Brukmana98cd452003-05-20 20:32:24 +0000232 MI = BuildMI(V9::OR, 3).addReg(tmpReg).addPCDisp(val).addRegDef(tmpReg);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000233 MI->setOperandLo64(1);
234 mvec.push_back(MI);
235
Misha Brukmana98cd452003-05-20 20:32:24 +0000236 mvec.push_back(BuildMI(V9::SLLX, 3).addReg(tmpReg).addZImm(32)
237 .addRegDef(tmpReg));
238 MI = BuildMI(V9::SETHI, 2).addPCDisp(val).addRegDef(dest);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000239 MI->setOperandHi32(0);
240 mvec.push_back(MI);
241
Misha Brukmana98cd452003-05-20 20:32:24 +0000242 MI = BuildMI(V9::OR, 3).addReg(dest).addReg(tmpReg).addRegDef(dest);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000243 mvec.push_back(MI);
244
Misha Brukmana98cd452003-05-20 20:32:24 +0000245 MI = BuildMI(V9::OR, 3).addReg(dest).addPCDisp(val).addRegDef(dest);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000246 MI->setOperandLo32(1);
247 mvec.push_back(MI);
248}
249
Vikram S. Adve30764b82001-10-18 00:01:48 +0000250
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000251//----------------------------------------------------------------------------
252// Function: CreateUIntSetInstruction
253//
254// Create code to Set an unsigned constant in the register `dest'.
255// Uses CreateSETUWConst, CreateSETSWConst or CreateSETXConst as needed.
256// CreateSETSWConst is an optimization for the case that the unsigned value
257// has all ones in the 33 high bits (so that sign-extension sets them all).
258//----------------------------------------------------------------------------
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000259
Vikram S. Adve242a8082002-05-19 15:25:51 +0000260static inline void
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000261CreateUIntSetInstruction(const TargetMachine& target,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000262 uint64_t C, Instruction* dest,
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000263 std::vector<MachineInstr*>& mvec,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000264 MachineCodeForInstruction& mcfi)
Vikram S. Advecee9d1c2001-12-15 00:33:36 +0000265{
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000266 static const uint64_t lo32 = (uint32_t) ~0;
267 if (C <= lo32) // High 32 bits are 0. Set low 32 bits.
268 CreateSETUWConst(target, (uint32_t) C, dest, mvec);
269 else if ((C & ~lo32) == ~lo32 && (C & (1 << 31)))
270 { // All high 33 (not 32) bits are 1s: sign-extension will take care
271 // of high 32 bits, so use the sequence for signed int
272 CreateSETSWConst(target, (int32_t) C, dest, mvec);
273 }
274 else if (C > lo32)
Vikram S. Advecee9d1c2001-12-15 00:33:36 +0000275 { // C does not fit in 32 bits
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000276 TmpInstruction* tmpReg = new TmpInstruction(Type::IntTy);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000277 mcfi.addTemp(tmpReg);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000278 CreateSETXConst(target, C, tmpReg, dest, mvec);
Vikram S. Advecee9d1c2001-12-15 00:33:36 +0000279 }
Vikram S. Adve30764b82001-10-18 00:01:48 +0000280}
281
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000282
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000283//----------------------------------------------------------------------------
284// Function: CreateIntSetInstruction
285//
286// Create code to Set a signed constant in the register `dest'.
287// Really the same as CreateUIntSetInstruction.
288//----------------------------------------------------------------------------
289
290static inline void
291CreateIntSetInstruction(const TargetMachine& target,
292 int64_t C, Instruction* dest,
293 std::vector<MachineInstr*>& mvec,
294 MachineCodeForInstruction& mcfi)
295{
296 CreateUIntSetInstruction(target, (uint64_t) C, dest, mvec, mcfi);
297}
Chris Lattner035dfbe2002-08-09 20:08:06 +0000298
Vikram S. Adve30764b82001-10-18 00:01:48 +0000299
300//---------------------------------------------------------------------------
Vikram S. Adve49001162002-09-16 15:56:01 +0000301// Create a table of LLVM opcode -> max. immediate constant likely to
302// be usable for that operation.
303//---------------------------------------------------------------------------
304
305// Entry == 0 ==> no immediate constant field exists at all.
306// Entry > 0 ==> abs(immediate constant) <= Entry
307//
Misha Brukmana98cd452003-05-20 20:32:24 +0000308std::vector<int> MaxConstantsTable(Instruction::OtherOpsEnd);
Vikram S. Adve49001162002-09-16 15:56:01 +0000309
310static int
311MaxConstantForInstr(unsigned llvmOpCode)
312{
313 int modelOpCode = -1;
314
Chris Lattner0b16ae22002-10-13 19:39:16 +0000315 if (llvmOpCode >= Instruction::BinaryOpsBegin &&
316 llvmOpCode < Instruction::BinaryOpsEnd)
Misha Brukmana98cd452003-05-20 20:32:24 +0000317 modelOpCode = V9::ADD;
Vikram S. Adve49001162002-09-16 15:56:01 +0000318 else
319 switch(llvmOpCode) {
Misha Brukmana98cd452003-05-20 20:32:24 +0000320 case Instruction::Ret: modelOpCode = V9::JMPLCALL; break;
Vikram S. Adve49001162002-09-16 15:56:01 +0000321
322 case Instruction::Malloc:
323 case Instruction::Alloca:
324 case Instruction::GetElementPtr:
325 case Instruction::PHINode:
326 case Instruction::Cast:
Misha Brukmana98cd452003-05-20 20:32:24 +0000327 case Instruction::Call: modelOpCode = V9::ADD; break;
Vikram S. Adve49001162002-09-16 15:56:01 +0000328
329 case Instruction::Shl:
Misha Brukmana98cd452003-05-20 20:32:24 +0000330 case Instruction::Shr: modelOpCode = V9::SLLX; break;
Vikram S. Adve49001162002-09-16 15:56:01 +0000331
332 default: break;
333 };
334
335 return (modelOpCode < 0)? 0: SparcMachineInstrDesc[modelOpCode].maxImmedConst;
336}
337
338static void
339InitializeMaxConstantsTable()
340{
341 unsigned op;
Chris Lattner0b16ae22002-10-13 19:39:16 +0000342 assert(MaxConstantsTable.size() == Instruction::OtherOpsEnd &&
Vikram S. Adve49001162002-09-16 15:56:01 +0000343 "assignments below will be illegal!");
Chris Lattner0b16ae22002-10-13 19:39:16 +0000344 for (op = Instruction::TermOpsBegin; op < Instruction::TermOpsEnd; ++op)
Vikram S. Adve49001162002-09-16 15:56:01 +0000345 MaxConstantsTable[op] = MaxConstantForInstr(op);
Chris Lattner0b16ae22002-10-13 19:39:16 +0000346 for (op = Instruction::BinaryOpsBegin; op < Instruction::BinaryOpsEnd; ++op)
Vikram S. Adve49001162002-09-16 15:56:01 +0000347 MaxConstantsTable[op] = MaxConstantForInstr(op);
Chris Lattner0b16ae22002-10-13 19:39:16 +0000348 for (op = Instruction::MemoryOpsBegin; op < Instruction::MemoryOpsEnd; ++op)
Vikram S. Adve49001162002-09-16 15:56:01 +0000349 MaxConstantsTable[op] = MaxConstantForInstr(op);
Chris Lattner0b16ae22002-10-13 19:39:16 +0000350 for (op = Instruction::OtherOpsBegin; op < Instruction::OtherOpsEnd; ++op)
Vikram S. Adve49001162002-09-16 15:56:01 +0000351 MaxConstantsTable[op] = MaxConstantForInstr(op);
352}
353
354
355//---------------------------------------------------------------------------
Vikram S. Adve30764b82001-10-18 00:01:48 +0000356// class UltraSparcInstrInfo
357//
358// Purpose:
359// Information about individual instructions.
360// Most information is stored in the SparcMachineInstrDesc array above.
361// Other information is computed on demand, and most such functions
Chris Lattner3501fea2003-01-14 22:00:31 +0000362// default to member functions in base class TargetInstrInfo.
Vikram S. Adve30764b82001-10-18 00:01:48 +0000363//---------------------------------------------------------------------------
364
365/*ctor*/
Chris Lattner047bbaf2002-10-29 15:45:20 +0000366UltraSparcInstrInfo::UltraSparcInstrInfo()
Chris Lattner3501fea2003-01-14 22:00:31 +0000367 : TargetInstrInfo(SparcMachineInstrDesc,
Misha Brukmana98cd452003-05-20 20:32:24 +0000368 /*descSize = */ V9::NUM_TOTAL_OPCODES,
369 /*numRealOpCodes = */ V9::NUM_REAL_OPCODES)
Vikram S. Adve30764b82001-10-18 00:01:48 +0000370{
Vikram S. Adve49001162002-09-16 15:56:01 +0000371 InitializeMaxConstantsTable();
372}
373
374bool
375UltraSparcInstrInfo::ConstantMayNotFitInImmedField(const Constant* CV,
376 const Instruction* I) const
377{
378 if (I->getOpcode() >= MaxConstantsTable.size()) // user-defined op (or bug!)
379 return true;
380
381 if (isa<ConstantPointerNull>(CV)) // can always use %g0
382 return false;
383
384 if (const ConstantUInt* U = dyn_cast<ConstantUInt>(CV))
Vikram S. Adve893cace2002-10-13 00:04:26 +0000385 /* Large unsigned longs may really just be small negative signed longs */
386 return (labs((int64_t) U->getValue()) > MaxConstantsTable[I->getOpcode()]);
Vikram S. Adve49001162002-09-16 15:56:01 +0000387
388 if (const ConstantSInt* S = dyn_cast<ConstantSInt>(CV))
Vikram S. Adve893cace2002-10-13 00:04:26 +0000389 return (labs(S->getValue()) > MaxConstantsTable[I->getOpcode()]);
Vikram S. Adve49001162002-09-16 15:56:01 +0000390
391 if (isa<ConstantBool>(CV))
Vikram S. Adve893cace2002-10-13 00:04:26 +0000392 return (1 > MaxConstantsTable[I->getOpcode()]);
Vikram S. Adve49001162002-09-16 15:56:01 +0000393
394 return true;
Vikram S. Adve30764b82001-10-18 00:01:48 +0000395}
396
Vikram S. Advee76af292002-03-18 03:09:15 +0000397//
Vikram S. Adve30764b82001-10-18 00:01:48 +0000398// Create an instruction sequence to put the constant `val' into
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000399// the virtual register `dest'. `val' may be a Constant or a
Vikram S. Adve30764b82001-10-18 00:01:48 +0000400// GlobalValue, viz., the constant address of a global variable or function.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000401// The generated instructions are returned in `mvec'.
402// Any temp. registers (TmpInstruction) created are recorded in mcfi.
Misha Brukmanfce11432002-10-28 00:28:31 +0000403// Any stack space required is allocated via MachineFunction.
Vikram S. Adve30764b82001-10-18 00:01:48 +0000404//
405void
Vikram S. Adve242a8082002-05-19 15:25:51 +0000406UltraSparcInstrInfo::CreateCodeToLoadConst(const TargetMachine& target,
407 Function* F,
408 Value* val,
Vikram S. Advee76af292002-03-18 03:09:15 +0000409 Instruction* dest,
Misha Brukmana98cd452003-05-20 20:32:24 +0000410 std::vector<MachineInstr*>& mvec,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000411 MachineCodeForInstruction& mcfi) const
Vikram S. Adve30764b82001-10-18 00:01:48 +0000412{
Chris Lattnere9bb2df2001-12-03 22:26:30 +0000413 assert(isa<Constant>(val) || isa<GlobalValue>(val) &&
Vikram S. Adve30764b82001-10-18 00:01:48 +0000414 "I only know about constant values and global addresses");
415
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000416 // Use a "set" instruction for known constants or symbolic constants (labels)
417 // that can go in an integer reg.
418 // We have to use a "load" instruction for all other constants,
419 // in particular, floating point constants.
Vikram S. Adve30764b82001-10-18 00:01:48 +0000420 //
421 const Type* valType = val->getType();
422
Vikram S. Adve893cace2002-10-13 00:04:26 +0000423 // Unfortunate special case: a ConstantPointerRef is just a
424 // reference to GlobalValue.
425 if (isa<ConstantPointerRef>(val))
426 val = cast<ConstantPointerRef>(val)->getValue();
427
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000428 if (isa<GlobalValue>(val))
Vikram S. Adve30764b82001-10-18 00:01:48 +0000429 {
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000430 TmpInstruction* tmpReg =
431 new TmpInstruction(PointerType::get(val->getType()), val);
432 mcfi.addTemp(tmpReg);
433 CreateSETXLabel(target, val, tmpReg, dest, mvec);
434 }
Chris Lattner0c4e8862002-09-03 01:08:28 +0000435 else if (valType->isIntegral())
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000436 {
437 bool isValidConstant;
Chris Lattner2ef9a6a2002-12-28 20:18:21 +0000438 unsigned opSize = target.getTargetData().getTypeSize(val->getType());
439 unsigned destSize = target.getTargetData().getTypeSize(dest->getType());
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000440
441 if (! dest->getType()->isSigned())
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000442 {
Vikram S. Advea40cbb32002-08-04 20:55:37 +0000443 uint64_t C = GetConstantValueAsUnsignedInt(val, isValidConstant);
444 assert(isValidConstant && "Unrecognized constant");
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000445
Chris Lattner7a5adc32003-04-26 19:44:35 +0000446 if (opSize > destSize || (val->getType()->isSigned() && destSize < 8))
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000447 { // operand is larger than dest,
448 // OR both are equal but smaller than the full register size
449 // AND operand is signed, so it may have extra sign bits:
450 // mask high bits
451 C = C & ((1U << 8*destSize) - 1);
452 }
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000453 CreateUIntSetInstruction(target, C, dest, mvec, mcfi);
Vikram S. Advecee9d1c2001-12-15 00:33:36 +0000454 }
455 else
456 {
Vikram S. Advecee9d1c2001-12-15 00:33:36 +0000457 int64_t C = GetConstantValueAsSignedInt(val, isValidConstant);
458 assert(isValidConstant && "Unrecognized constant");
Vikram S. Adve6c0c3012002-08-13 18:04:08 +0000459
460 if (opSize > destSize)
461 // operand is larger than dest: mask high bits
462 C = C & ((1U << 8*destSize) - 1);
463
464 if (opSize > destSize ||
465 (opSize == destSize && !val->getType()->isSigned()))
466 // sign-extend from destSize to 64 bits
467 C = ((C & (1U << (8*destSize - 1)))
468 ? C | ~((1U << 8*destSize) - 1)
469 : C);
470
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000471 CreateIntSetInstruction(target, C, dest, mvec, mcfi);
Vikram S. Advecee9d1c2001-12-15 00:33:36 +0000472 }
Vikram S. Adve30764b82001-10-18 00:01:48 +0000473 }
474 else
475 {
476 // Make an instruction sequence to load the constant, viz:
Vikram S. Advea2a70942001-10-28 21:41:46 +0000477 // SETX <addr-of-constant>, tmpReg, addrReg
Vikram S. Adve30764b82001-10-18 00:01:48 +0000478 // LOAD /*addr*/ addrReg, /*offset*/ 0, dest
Vikram S. Adve30764b82001-10-18 00:01:48 +0000479
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000480 // First, create a tmp register to be used by the SETX sequence.
Vikram S. Advea2a70942001-10-28 21:41:46 +0000481 TmpInstruction* tmpReg =
Chris Lattnercb0a1202002-02-03 07:49:49 +0000482 new TmpInstruction(PointerType::get(val->getType()), val);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000483 mcfi.addTemp(tmpReg);
Vikram S. Advea2a70942001-10-28 21:41:46 +0000484
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000485 // Create another TmpInstruction for the address register
486 TmpInstruction* addrReg =
Chris Lattnercb0a1202002-02-03 07:49:49 +0000487 new TmpInstruction(PointerType::get(val->getType()), val);
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000488 mcfi.addTemp(addrReg);
Vikram S. Adve30764b82001-10-18 00:01:48 +0000489
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000490 // Put the address (a symbolic name) into a register
491 CreateSETXLabel(target, val, tmpReg, addrReg, mvec);
Vikram S. Adve30764b82001-10-18 00:01:48 +0000492
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000493 // Generate the load instruction
494 int64_t zeroOffset = 0; // to avoid ambiguity with (Value*) 0
Chris Lattnere5b1ed92003-01-15 00:03:28 +0000495 unsigned Opcode = ChooseLoadInstruction(val->getType());
496 mvec.push_back(BuildMI(Opcode, 3).addReg(addrReg).
Chris Lattner00dca912003-01-15 17:47:49 +0000497 addSImm(zeroOffset).addRegDef(dest));
Vikram S. Adve53fd4002002-07-10 21:39:50 +0000498
499 // Make sure constant is emitted to constant pool in assembly code.
Chris Lattner2ef9a6a2002-12-28 20:18:21 +0000500 MachineFunction::get(F).getInfo()->addToConstantPool(cast<Constant>(val));
Vikram S. Adve30764b82001-10-18 00:01:48 +0000501 }
502}
503
504
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000505// Create an instruction sequence to copy an integer register `val'
506// to a floating point register `dest' by copying to memory and back.
Vikram S. Adve5b6082e2001-11-09 02:16:40 +0000507// val must be an integral type. dest must be a Float or Double.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000508// The generated instructions are returned in `mvec'.
509// Any temp. registers (TmpInstruction) created are recorded in mcfi.
Misha Brukmanfce11432002-10-28 00:28:31 +0000510// Any stack space required is allocated via MachineFunction.
Vikram S. Adveb9c38632001-11-08 04:57:53 +0000511//
512void
Vikram S. Adve242a8082002-05-19 15:25:51 +0000513UltraSparcInstrInfo::CreateCodeToCopyIntToFloat(const TargetMachine& target,
514 Function* F,
515 Value* val,
516 Instruction* dest,
Misha Brukmana98cd452003-05-20 20:32:24 +0000517 std::vector<MachineInstr*>& mvec,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000518 MachineCodeForInstruction& mcfi) const
Vikram S. Adveb9c38632001-11-08 04:57:53 +0000519{
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000520 assert((val->getType()->isIntegral() || isa<PointerType>(val->getType()))
521 && "Source type must be integral (integer or bool) or pointer");
Chris Lattner9b625032002-05-06 16:15:30 +0000522 assert(dest->getType()->isFloatingPoint()
Vikram S. Adveb9c38632001-11-08 04:57:53 +0000523 && "Dest type must be float/double");
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000524
525 // Get a stack slot to use for the copy
Chris Lattner2ef9a6a2002-12-28 20:18:21 +0000526 int offset = MachineFunction::get(F).getInfo()->allocateLocalVar(val);
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000527
528 // Get the size of the source value being copied.
Chris Lattner2ef9a6a2002-12-28 20:18:21 +0000529 size_t srcSize = target.getTargetData().getTypeSize(val->getType());
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000530
Vikram S. Adveb9c38632001-11-08 04:57:53 +0000531 // Store instruction stores `val' to [%fp+offset].
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000532 // The store and load opCodes are based on the size of the source value.
533 // If the value is smaller than 32 bits, we must sign- or zero-extend it
534 // to 32 bits since the load-float will load 32 bits.
Vikram S. Advec190c012002-07-31 21:13:31 +0000535 // Note that the store instruction is the same for signed and unsigned ints.
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000536 const Type* storeType = (srcSize <= 4)? Type::IntTy : Type::LongTy;
537 Value* storeVal = val;
Chris Lattner2ef9a6a2002-12-28 20:18:21 +0000538 if (srcSize < target.getTargetData().getTypeSize(Type::FloatTy))
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000539 { // sign- or zero-extend respectively
540 storeVal = new TmpInstruction(storeType, val);
541 if (val->getType()->isSigned())
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000542 CreateSignExtensionInstructions(target, F, val, storeVal, 8*srcSize,
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000543 mvec, mcfi);
544 else
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000545 CreateZeroExtensionInstructions(target, F, val, storeVal, 8*srcSize,
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000546 mvec, mcfi);
547 }
Chris Lattner54e898e2003-01-15 19:23:34 +0000548
549 unsigned FPReg = target.getRegInfo().getFramePointer();
550 mvec.push_back(BuildMI(ChooseStoreInstruction(storeType), 3)
551 .addReg(storeVal).addMReg(FPReg).addSImm(offset));
Vikram S. Adve30764b82001-10-18 00:01:48 +0000552
Vikram S. Adveb9c38632001-11-08 04:57:53 +0000553 // Load instruction loads [%fp+offset] to `dest'.
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000554 // The type of the load opCode is the floating point type that matches the
555 // stored type in size:
556 // On SparcV9: float for int or smaller, double for long.
Vikram S. Adve5b6082e2001-11-09 02:16:40 +0000557 //
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000558 const Type* loadType = (srcSize <= 4)? Type::FloatTy : Type::DoubleTy;
Chris Lattner54e898e2003-01-15 19:23:34 +0000559 mvec.push_back(BuildMI(ChooseLoadInstruction(loadType), 3)
560 .addMReg(FPReg).addSImm(offset).addRegDef(dest));
Vikram S. Adve5b6082e2001-11-09 02:16:40 +0000561}
562
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000563// Similarly, create an instruction sequence to copy an FP register
564// `val' to an integer register `dest' by copying to memory and back.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000565// The generated instructions are returned in `mvec'.
566// Any temp. registers (TmpInstruction) created are recorded in mcfi.
Misha Brukmanfce11432002-10-28 00:28:31 +0000567// Any stack space required is allocated via MachineFunction.
Vikram S. Adve5b6082e2001-11-09 02:16:40 +0000568//
569void
Vikram S. Adve242a8082002-05-19 15:25:51 +0000570UltraSparcInstrInfo::CreateCodeToCopyFloatToInt(const TargetMachine& target,
571 Function* F,
Chris Lattner697954c2002-01-20 22:54:45 +0000572 Value* val,
573 Instruction* dest,
Misha Brukmana98cd452003-05-20 20:32:24 +0000574 std::vector<MachineInstr*>& mvec,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000575 MachineCodeForInstruction& mcfi) const
Vikram S. Adve5b6082e2001-11-09 02:16:40 +0000576{
Vikram S. Advec190c012002-07-31 21:13:31 +0000577 const Type* opTy = val->getType();
578 const Type* destTy = dest->getType();
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000579
Vikram S. Advec190c012002-07-31 21:13:31 +0000580 assert(opTy->isFloatingPoint() && "Source type must be float/double");
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000581 assert((destTy->isIntegral() || isa<PointerType>(destTy))
582 && "Dest type must be integer, bool or pointer");
Vikram S. Advec190c012002-07-31 21:13:31 +0000583
Chris Lattner2ef9a6a2002-12-28 20:18:21 +0000584 int offset = MachineFunction::get(F).getInfo()->allocateLocalVar(val);
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000585
Chris Lattner54e898e2003-01-15 19:23:34 +0000586 unsigned FPReg = target.getRegInfo().getFramePointer();
587
Vikram S. Adve5b6082e2001-11-09 02:16:40 +0000588 // Store instruction stores `val' to [%fp+offset].
Vikram S. Advec190c012002-07-31 21:13:31 +0000589 // The store opCode is based only the source value being copied.
Vikram S. Adve5b6082e2001-11-09 02:16:40 +0000590 //
Chris Lattner54e898e2003-01-15 19:23:34 +0000591 mvec.push_back(BuildMI(ChooseStoreInstruction(opTy), 3)
592 .addReg(val).addMReg(FPReg).addSImm(offset));
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000593
Vikram S. Adve5b6082e2001-11-09 02:16:40 +0000594 // Load instruction loads [%fp+offset] to `dest'.
Vikram S. Advec190c012002-07-31 21:13:31 +0000595 // The type of the load opCode is the integer type that matches the
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000596 // source type in size:
Vikram S. Advec190c012002-07-31 21:13:31 +0000597 // On SparcV9: int for float, long for double.
598 // Note that we *must* use signed loads even for unsigned dest types, to
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000599 // ensure correct sign-extension for UByte, UShort or UInt:
600 //
601 const Type* loadTy = (opTy == Type::FloatTy)? Type::IntTy : Type::LongTy;
Chris Lattner54e898e2003-01-15 19:23:34 +0000602 mvec.push_back(BuildMI(ChooseLoadInstruction(loadTy), 3).addMReg(FPReg)
603 .addSImm(offset).addRegDef(dest));
Vikram S. Adve242a8082002-05-19 15:25:51 +0000604}
605
606
607// Create instruction(s) to copy src to dest, for arbitrary types
608// The generated instructions are returned in `mvec'.
609// Any temp. registers (TmpInstruction) created are recorded in mcfi.
Misha Brukmanfce11432002-10-28 00:28:31 +0000610// Any stack space required is allocated via MachineFunction.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000611//
612void
613UltraSparcInstrInfo::CreateCopyInstructionsByType(const TargetMachine& target,
614 Function *F,
615 Value* src,
616 Instruction* dest,
Misha Brukmana98cd452003-05-20 20:32:24 +0000617 std::vector<MachineInstr*>& mvec,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000618 MachineCodeForInstruction& mcfi) const
619{
620 bool loadConstantToReg = false;
621
622 const Type* resultType = dest->getType();
623
624 MachineOpCode opCode = ChooseAddInstructionByType(resultType);
Misha Brukmana98cd452003-05-20 20:32:24 +0000625 if (opCode == V9::INVALID_OPCODE)
626 {
627 assert(0 && "Unsupported result type in CreateCopyInstructionsByType()");
628 return;
629 }
Vikram S. Adve242a8082002-05-19 15:25:51 +0000630
631 // if `src' is a constant that doesn't fit in the immed field or if it is
632 // a global variable (i.e., a constant address), generate a load
633 // instruction instead of an add
634 //
635 if (isa<Constant>(src))
Misha Brukmana98cd452003-05-20 20:32:24 +0000636 {
637 unsigned int machineRegNum;
638 int64_t immedValue;
639 MachineOperand::MachineOperandType opType =
640 ChooseRegOrImmed(src, opCode, target, /*canUseImmed*/ true,
641 machineRegNum, immedValue);
Vikram S. Adve242a8082002-05-19 15:25:51 +0000642
Misha Brukmana98cd452003-05-20 20:32:24 +0000643 if (opType == MachineOperand::MO_VirtualRegister)
644 loadConstantToReg = true;
645 }
Vikram S. Adve242a8082002-05-19 15:25:51 +0000646 else if (isa<GlobalValue>(src))
647 loadConstantToReg = true;
648
649 if (loadConstantToReg)
Misha Brukmana98cd452003-05-20 20:32:24 +0000650 { // `src' is constant and cannot fit in immed field for the ADD
651 // Insert instructions to "load" the constant into a register
652 target.getInstrInfo().CreateCodeToLoadConst(target, F, src, dest,
653 mvec, mcfi);
654 }
Vikram S. Adve242a8082002-05-19 15:25:51 +0000655 else
Misha Brukmana98cd452003-05-20 20:32:24 +0000656 { // Create an add-with-0 instruction of the appropriate type.
657 // Make `src' the second operand, in case it is a constant
658 // Use (unsigned long) 0 for a NULL pointer value.
659 //
660 const Type* Ty =isa<PointerType>(resultType) ? Type::ULongTy : resultType;
661 MachineInstr* MI =
662 BuildMI(opCode, 3).addReg(Constant::getNullValue(Ty))
663 .addReg(src).addRegDef(dest);
664 mvec.push_back(MI);
665 }
Vikram S. Adve242a8082002-05-19 15:25:51 +0000666}
667
668
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000669// Helper function for sign-extension and zero-extension.
670// For SPARC v9, we sign-extend the given operand using SLL; SRA/SRL.
671inline void
672CreateBitExtensionInstructions(bool signExtend,
673 const TargetMachine& target,
674 Function* F,
675 Value* srcVal,
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000676 Value* destVal,
677 unsigned int numLowBits,
Misha Brukmana98cd452003-05-20 20:32:24 +0000678 std::vector<MachineInstr*>& mvec,
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000679 MachineCodeForInstruction& mcfi)
680{
681 MachineInstr* M;
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000682
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000683 assert(numLowBits <= 32 && "Otherwise, nothing should be done here!");
684
685 if (numLowBits < 32)
Misha Brukmana98cd452003-05-20 20:32:24 +0000686 { // SLL is needed since operand size is < 32 bits.
687 TmpInstruction *tmpI = new TmpInstruction(destVal->getType(),
688 srcVal, destVal, "make32");
689 mcfi.addTemp(tmpI);
690 mvec.push_back(BuildMI(V9::SLLX, 3).addReg(srcVal)
691 .addZImm(32-numLowBits).addRegDef(tmpI));
692 srcVal = tmpI;
693 }
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000694
Misha Brukmana98cd452003-05-20 20:32:24 +0000695 mvec.push_back(BuildMI(signExtend? V9::SRA : V9::SRL, 3)
696 .addReg(srcVal).addZImm(32-numLowBits).addRegDef(destVal));
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000697}
698
699
Vikram S. Adve242a8082002-05-19 15:25:51 +0000700// Create instruction sequence to produce a sign-extended register value
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000701// from an arbitrary-sized integer value (sized in bits, not bytes).
Vikram S. Adve242a8082002-05-19 15:25:51 +0000702// The generated instructions are returned in `mvec'.
703// Any temp. registers (TmpInstruction) created are recorded in mcfi.
Misha Brukmanfce11432002-10-28 00:28:31 +0000704// Any stack space required is allocated via MachineFunction.
Vikram S. Adve242a8082002-05-19 15:25:51 +0000705//
706void
707UltraSparcInstrInfo::CreateSignExtensionInstructions(
708 const TargetMachine& target,
709 Function* F,
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000710 Value* srcVal,
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000711 Value* destVal,
712 unsigned int numLowBits,
Misha Brukmana98cd452003-05-20 20:32:24 +0000713 std::vector<MachineInstr*>& mvec,
Vikram S. Adve242a8082002-05-19 15:25:51 +0000714 MachineCodeForInstruction& mcfi) const
715{
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000716 CreateBitExtensionInstructions(/*signExtend*/ true, target, F, srcVal,
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000717 destVal, numLowBits, mvec, mcfi);
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000718}
719
720
721// Create instruction sequence to produce a zero-extended register value
722// from an arbitrary-sized integer value (sized in bits, not bytes).
723// For SPARC v9, we sign-extend the given operand using SLL; SRL.
724// The generated instructions are returned in `mvec'.
725// Any temp. registers (TmpInstruction) created are recorded in mcfi.
Misha Brukmanfce11432002-10-28 00:28:31 +0000726// Any stack space required is allocated via MachineFunction.
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000727//
728void
729UltraSparcInstrInfo::CreateZeroExtensionInstructions(
730 const TargetMachine& target,
731 Function* F,
732 Value* srcVal,
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000733 Value* destVal,
734 unsigned int numLowBits,
Misha Brukmana98cd452003-05-20 20:32:24 +0000735 std::vector<MachineInstr*>& mvec,
Vikram S. Adve84c0fcb2002-09-05 18:33:59 +0000736 MachineCodeForInstruction& mcfi) const
737{
738 CreateBitExtensionInstructions(/*signExtend*/ false, target, F, srcVal,
Vikram S. Adve5cedede2002-09-27 14:29:45 +0000739 destVal, numLowBits, mvec, mcfi);
Vikram S. Adveb9c38632001-11-08 04:57:53 +0000740}