1 //===-- Thumb2HazardRecognizer.cpp - Thumb2 postra hazard recognizer ------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 #include "Thumb2HazardRecognizer.h"
12 #include "llvm/CodeGen/MachineInstr.h"
13 #include "llvm/CodeGen/ScheduleDAG.h"
16 ScheduleHazardRecognizer::HazardType
17 Thumb2HazardRecognizer::getHazardType(SUnit *SU) {
19 MachineInstr *MI = SU->getInstr();
20 if (!MI->isDebugValue() && MI != ITBlockMIs[ITBlockSize-1])
24 return PostRAHazardRecognizer::getHazardType(SU);
27 void Thumb2HazardRecognizer::Reset() {
29 PostRAHazardRecognizer::Reset();
32 void Thumb2HazardRecognizer::EmitInstruction(SUnit *SU) {
33 MachineInstr *MI = SU->getInstr();
34 unsigned Opcode = MI->getOpcode();
37 } else if (Opcode == ARM::t2IT) {
38 unsigned Mask = MI->getOperand(1).getImm();
39 unsigned NumTZ = CountTrailingZeros_32(Mask);
40 assert(NumTZ <= 3 && "Invalid IT mask!");
41 ITBlockSize = 4 - NumTZ;
42 MachineBasicBlock::iterator I = MI;
43 for (unsigned i = 0; i < ITBlockSize; ++i) {
44 // Advance to the next instruction, skipping any dbg_value instructions.
47 } while (I->isDebugValue());
48 ITBlockMIs[ITBlockSize-1-i] = &*I;
52 PostRAHazardRecognizer::EmitInstruction(SU);