1//===-- RISCVInstrInfoM.td - RISC-V 'M' instructions -------*- tablegen -*-===// 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// 10// This file describes the RISC-V instructions from the standard 'M', Integer 11// Multiplication and Division instruction set extension. 12// 13//===----------------------------------------------------------------------===// 14 15//===----------------------------------------------------------------------===// 16// Instructions 17//===----------------------------------------------------------------------===// 18 19let Predicates = [HasStdExtM] in { 20def MUL : ALU_rr<0b0000001, 0b000, "mul">; 21def MULH : ALU_rr<0b0000001, 0b001, "mulh">; 22def MULHSU : ALU_rr<0b0000001, 0b010, "mulhsu">; 23def MULHU : ALU_rr<0b0000001, 0b011, "mulhu">; 24def DIV : ALU_rr<0b0000001, 0b100, "div">; 25def DIVU : ALU_rr<0b0000001, 0b101, "divu">; 26def REM : ALU_rr<0b0000001, 0b110, "rem">; 27def REMU : ALU_rr<0b0000001, 0b111, "remu">; 28} // Predicates = [HasStdExtM] 29 30let Predicates = [HasStdExtM, IsRV64] in { 31def MULW : ALUW_rr<0b0000001, 0b000, "mulw">; 32def DIVW : ALUW_rr<0b0000001, 0b100, "divw">; 33def DIVUW : ALUW_rr<0b0000001, 0b101, "divuw">; 34def REMW : ALUW_rr<0b0000001, 0b110, "remw">; 35def REMUW : ALUW_rr<0b0000001, 0b111, "remuw">; 36} // Predicates = [HasStdExtM, IsRV64] 37 38//===----------------------------------------------------------------------===// 39// Pseudo-instructions and codegen patterns 40//===----------------------------------------------------------------------===// 41 42let Predicates = [HasStdExtM] in { 43def : PatGprGpr<mul, MUL>; 44def : PatGprGpr<mulhs, MULH>; 45def : PatGprGpr<mulhu, MULHU>; 46// No ISDOpcode for mulhsu 47def : PatGprGpr<sdiv, DIV>; 48def : PatGprGpr<udiv, DIVU>; 49def : PatGprGpr<srem, REM>; 50def : PatGprGpr<urem, REMU>; 51} // Predicates = [HasStdExtM] 52