1 //===- X86LegalizerInfo.cpp --------------------------------------*- C++ -*-==// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is distributed under the University of Illinois Open Source 6 // License. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 /// \file 10 /// This file implements the targeting of the Machinelegalizer class for X86. 11 /// \todo This should be generated by TableGen. 12 //===----------------------------------------------------------------------===// 13 14 #include "X86LegalizerInfo.h" 15 #include "X86Subtarget.h" 16 #include "llvm/CodeGen/ValueTypes.h" 17 #include "llvm/IR/DerivedTypes.h" 18 #include "llvm/IR/Type.h" 19 #include "llvm/Target/TargetOpcodes.h" 20 21 using namespace llvm; 22 23 #ifndef LLVM_BUILD_GLOBAL_ISEL 24 #error "You shouldn't build this" 25 #endif 26 27 X86LegalizerInfo::X86LegalizerInfo(const X86Subtarget &STI) : Subtarget(STI) { 28 29 setLegalizerInfo32bit(); 30 setLegalizerInfo64bit(); 31 32 computeTables(); 33 } 34 35 void X86LegalizerInfo::setLegalizerInfo32bit() { 36 37 const LLT s8 = LLT::scalar(8); 38 const LLT s16 = LLT::scalar(16); 39 const LLT s32 = LLT::scalar(32); 40 41 for (auto Ty : {s8, s16, s32}) { 42 setAction({TargetOpcode::G_ADD, Ty}, Legal); 43 setAction({TargetOpcode::G_SUB, Ty}, Legal); 44 } 45 } 46 47 void X86LegalizerInfo::setLegalizerInfo64bit() { 48 49 if (!Subtarget.is64Bit()) 50 return; 51 52 const LLT s64 = LLT::scalar(64); 53 54 setAction({TargetOpcode::G_ADD, s64}, Legal); 55 setAction({TargetOpcode::G_SUB, s64}, Legal); 56 } 57