Index: include/llvm/Target/Target.td =================================================================== --- include/llvm/Target/Target.td +++ include/llvm/Target/Target.td @@ -1553,3 +1553,8 @@ // Pull in the common support for the Global ISel DAG-based selector generation. // include "llvm/Target/GlobalISel/SelectionDAGCompat.td" + +//===----------------------------------------------------------------------===// +// Pull in the common support for exegesis. +// +include "llvm/Target/TargetExegesis.td" Index: include/llvm/Target/TargetExegesis.td =================================================================== --- /dev/null +++ include/llvm/Target/TargetExegesis.td @@ -0,0 +1,52 @@ +//===- TargetSchedule.td - Target Independent Scheduling ---*- tablegen -*-===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +class OperandValue; + +class ExegesisConfiguration { + Instruction Instruction = ?; + list OperandValues; +} + +class ScalarValue : OperandValue; + +class PackedValue : OperandValue { + ScalarValue BroadcastValue; +} + +// Floating Point description + +class Ieee754Precision; +def HalfPrecision : Ieee754Precision; +def SinglePrecision : Ieee754Precision; +def DoublePrecision : Ieee754Precision; +def X87Precision : Ieee754Precision; + +class RawExponentValue; +def RawExponentZero : RawExponentValue; +def RawExponentMax : RawExponentValue; +def RawExponentBias : RawExponentValue; + +class MantissaValue; +def MantissaZero : MantissaValue; +def MantissaOne : MantissaValue; +def MantissaMax : MantissaValue; + +class Ieee754 : ScalarValue { + Ieee754Precision Precision; + bit Sign; + RawExponentValue Exponent; + MantissaValue Mantissa; +} + +// Integer Description. + +class Integer : ScalarValue { + list Bits; +} Index: lib/Target/X86/X86.td =================================================================== --- lib/Target/X86/X86.td +++ lib/Target/X86/X86.td @@ -1200,3 +1200,9 @@ //===----------------------------------------------------------------------===// include "X86PfmCounters.td" + +//===----------------------------------------------------------------------===// +// Exegesis Configurations +//===----------------------------------------------------------------------===// + +include "X86ExegesisConfigurations.td" Index: lib/Target/X86/X86ExegesisConfigurations.td =================================================================== --- /dev/null +++ lib/Target/X86/X86ExegesisConfigurations.td @@ -0,0 +1,27 @@ +def One : Ieee754 { + let Precision = SinglePrecision; + let Sign = 0; + let Exponent = RawExponentBias; + let Mantissa = MantissaZero; +} + +def OnePlusEpsilon : Ieee754 { + let Precision = SinglePrecision; + let Sign = 0; + let Exponent = RawExponentBias; + let Mantissa = MantissaOne; +} + +def PackedOnes : PackedValue { + let BroadcastValue = One; +} + +def PackedOnePlusEpsilons : PackedValue { + let BroadcastValue = OnePlusEpsilon; +} + +let Instruction = VDIVPDrr in { + def VDIVPDrrExegesisConfiguration : ExegesisConfiguration { + let OperandValues = [PackedOnes, PackedOnePlusEpsilons]; + } +} Index: utils/TableGen/InstrSemInfoEmitter.cpp =================================================================== --- /dev/null +++ utils/TableGen/InstrSemInfoEmitter.cpp @@ -0,0 +1,56 @@ + +#include "llvm/Support/raw_ostream.h" +#include "llvm/TableGen/Record.h" +#include "llvm/TableGen/TableGenBackend.h" + +using namespace llvm; + +namespace { + +class InstrInfoSemEmitter { + RecordKeeper &Records; + +public: + InstrInfoSemEmitter(RecordKeeper &R) : Records(R) {} + + void run(raw_ostream &OS); +}; + +void InstrInfoSemEmitter::run(raw_ostream &OS) { + { // FPI + Record *Class = Records.getClass("FPI"); + assert(Class); + OS << "#FPI\n"; + for (const auto &D : Records.getDefs()) + if (D.second->isSubClassOf(Class)) + OS << D.second->getName() << "\n"; + } + { // PD + Record *Class = Records.getClass("PD"); + assert(Class); + OS << "#PD\n"; + for (const auto &D : Records.getDefs()) + if (D.second->isSubClassOf(Class)) + OS << D.second->getName() << "\n"; + } + { // PS + Record *Class = Records.getClass("PS"); + assert(Class); + OS << "#PS\n"; + for (const auto &D : Records.getDefs()) + if (D.second->isSubClassOf(Class)) + OS << D.second->getName() << "\n"; + } +} + +} // end namespace + +namespace llvm { + +void EmitInstrSemInfo(RecordKeeper &RK, raw_ostream &OS) { + InstrInfoSemEmitter(RK).run(OS); +} + +} // namespace llvm + +// 0b 0 01111100 01000000000000000000000