1 //===-- RISCVLegalizerInfo.cpp ----------------------------------*- 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 /// \file 9 /// This file implements the targeting of the Machinelegalizer class for RISC-V. 10 /// \todo This should be generated by TableGen. 11 //===----------------------------------------------------------------------===// 12 13 #include "RISCVLegalizerInfo.h" 14 #include "RISCVSubtarget.h" 15 #include "llvm/CodeGen/TargetOpcodes.h" 16 #include "llvm/CodeGen/ValueTypes.h" 17 #include "llvm/IR/DerivedTypes.h" 18 #include "llvm/IR/Type.h" 19 20 using namespace llvm; 21 22 RISCVLegalizerInfo::RISCVLegalizerInfo(const RISCVSubtarget &ST) { 23 const unsigned XLen = ST.getXLen(); 24 const LLT XLenLLT = LLT::scalar(XLen); 25 26 using namespace TargetOpcode; 27 28 getActionDefinitionsBuilder({G_ADD, G_SUB, G_AND, G_OR, G_XOR}) 29 .legalFor({XLenLLT}) 30 .clampScalar(0, XLenLLT, XLenLLT); 31 32 getLegacyLegalizerInfo().computeTables(); 33 } 34