MimIR
MimIR is my Intermediate Representation
Loading...
Searching...
No Matches
mim::plug::nvptx::HostEmitter Class Reference
Inheritance diagram for mim::plug::nvptx::HostEmitter:
[legend]

Public Types

using Super = ll::Emitter
Public Types inherited from mim::plug::ll::Emitter
enum class  Rt {
  embed ,
  ext
}
 How the C runtime wrappers (compiled to a <name>.ll via add_mim_runtime) reach the output. More...
using Super = NestPhase<Lam>

Public Member Functions

 HostEmitter (World &world, std::ostream &ostream, std::optional< std::string > device_fatbin_file)
void start () final
 Actual entry.
void find_kernels (const Def *)
std::string prepare () override
void emit_epilogue (Lam *) override
std::optional< std::string > isa_targetspecific_intrinsic (ll::BB &, const Def *) final
Public Member Functions inherited from mim::plug::ll::Emitter
 Emitter (World &world, std::string name, std::ostream &ostream)
void visit (const Nest &) override
void emit_imported (Lam *)
void finalize ()
std::string emit_bb (BB &bb, const Def *def)
template<class... Args>
void declare (std::format_string< Args... > s, Args &&... args)
void rt_mode (Rt rt)
bool load_rt_module (std::string_view filename)
 Locates the runtime module rt/<filename> (produced by add_mim_runtime) in the driver's search paths, reads it, and stores it for Rt::embed splicing.
template<class... Args>
void declare_rt (std::format_string< Args... > sig, Args &&... args)
 Declares a runtime wrapper sig (implemented in a C runtime, see add_mim_runtime) and records that the runtime is required by this module.
Public Member Functions inherited from mim::NestPhase< Lam >
 NestPhase (World &world, std::string name, bool elide_empty, bool schedule=false)
 NestPhase (World &world, flags_t annex, bool elide_empty, bool schedule=false)
const Nest & nest () const
Public Member Functions inherited from mim::ClosedMutPhase< M >
 ClosedMutPhase (World &world, std::string name, bool elide_empty, bool schedule=false)
 ClosedMutPhase (World &world, flags_t annex, bool elide_empty, bool schedule=false)
bool elide_empty () const
bool schedule () const
Public Member Functions inherited from mim::Phase
 Phase (World &world, std::string name)
 Phase (World &world, flags_t annex)
virtual ~Phase ()=default
virtual std::unique_ptr< Phase > recreate ()
 Creates a new instance; needed by a fixed-point PhaseMan.
virtual void apply (const App *)
 Invoked if your Phase has additional args.
virtual void apply (Phase &)
 Dito, but invoked by Phase::recreate.
virtual bool redirects () const
 If true, Phase::create uses take_resolved().
virtual std::unique_ptr< Phase > take_resolved ()
 The Phase to use instead; nullptr means elide.
World & world ()
Driver & driver ()
const fe::Log & log () const
std::string_view name () const
flags_t annex () const
const fe::Vector< std::string > & args ()
 Command-line arguments passed to this Phase's plugin via -X <plugin>:<arg>.
bool todo () const
void invalidate (bool todo=true)
 Signals that another round of fixed-point iteration is required, either as part of.
virtual void run ()
 Entry point and generates some debug output; invokes Phase::start.
void profile_count (std::string_view key, uint64_t n=1)
 Adds n to the custom fe::Profiler counter key of the current run; no-op unless profiling is enabled.

Protected Member Functions

std::string convert (const Def *, bool simd=true) override
 Converts type to its LLVM representation as a value (simd) or in memory (!simd).
Protected Member Functions inherited from mim::plug::ll::Emitter
std::ostream & ostream () const
std::string emit (const Def *def)
 Recursively emits code.
std::string emit_unsafe (const Def *def)
 As above but yielding an empty string is permitted.
const Scheduler::Schedule & schedule () const
 The Scheduler::schedule of the function currently being emitted; see Emitter::visit.
std::string id (const Def *, bool force_bb=false) const
std::string convert_ret_pi (const Pi *)
std::optional< std::pair< nat_t, const Def * > > vectorize (const Def *type) const
 Lane count and element type if a value of type is an LLVM vector.
bool has_vec (const Def *type) const
 Whether type's value representation contains an LLVM vector and hence differs from its memory one.
void emit_phi (Lam *callee, const Def *phi, std::string arg, Lam *pred)
 Registers arg as an incoming phi value for phi in callee, coming from predecessor pred.
void emit_phi_args (Lam *callee, const App *app, Lam *pred)
 Wires all non-mem.M arguments of app into callee's phis, coming from predecessor pred.
virtual std::string emit_slot (BB &bb, const App *app, const Def *pointee, const Def *)
 Emits the storage backing a mem.slot of type pointee and yields the pointer value.
Protected Member Functions inherited from mim::ClosedMutPhase< M >
virtual void visit (M *)=0
M * root () const

Additional Inherited Members

Static Public Member Functions inherited from mim::Phase
static std::unique_ptr< Phase > create (const Flags2Phases &phases, const Def *def)
template<class A, class P>
static void hook (Flags2Phases &phases)
template<class P, class... Args>
static void run (Args &&... args)
 Runs a single Phase.
Public Attributes inherited from mim::plug::ll::Emitter
fe::Tab tab = fe::Tab::spaces()
Protected Attributes inherited from mim::plug::ll::Emitter
Lam * curr_lam_ = nullptr
std::ostream & ostream_
Scheduler scheduler_
Scheduler::Schedule schedule_
DefMap< std::string > locals_
std::array< DefMap< std::string >, 2 > types_
 Indexed by the simd flag of Emitter::convert.
LamMap< BB > lam2bb_
std::set< std::string > decls_
std::ostringstream type_decls_
std::ostringstream vars_decls_
std::ostringstream func_decls_
std::ostringstream func_impls_
LamMap< const Def * > simd_phi_
LamMap< std::pair< u64, bool > > loop_md_
bool simd_ = true
Rt rt_ = Rt::embed
bool rt_used_ = false
std::string rt_module_
Protected Attributes inherited from mim::Phase
std::string name_
Static Protected Attributes inherited from mim::plug::ll::Emitter
static constexpr u64 LoopMdBase = 1000
 Loop-metadata node id per ll.vec/ll.novec-annotated loop header, and whether it may vectorize; LoopMdBase and LoopMdBase + 1 hold the shared enable/disable hints, the per-loop nodes follow, clear of the ids the embedded runtime module brings along.

Detailed Description

Definition at line 27 of file nvptx.cpp.

Member Typedef Documentation

◆ Super

Definition at line 29 of file nvptx.cpp.

Constructor & Destructor Documentation

◆ HostEmitter()

mim::plug::nvptx::HostEmitter::HostEmitter ( World & world,
std::ostream & ostream,
std::optional< std::string > device_fatbin_file )
inline

Definition at line 31 of file nvptx.cpp.

References mim::plug::ll::Emitter::ostream(), and mim::Phase::world().

Member Function Documentation

◆ convert()

std::string mim::plug::nvptx::HostEmitter::convert ( const Def * type,
bool simd = true )
overrideprotectedvirtual

Converts type to its LLVM representation as a value (simd) or in memory (!simd).

Only values use LLVM vectors; memory keeps the plain array layout C expects.

Reimplemented from mim::plug::ll::Emitter.

Definition at line 280 of file nvptx.cpp.

References mim::plug::ll::Emitter::convert(), mim::Axm::isa(), and mim::Lit::isa().

Referenced by isa_targetspecific_intrinsic().

◆ emit_epilogue()

void mim::plug::nvptx::HostEmitter::emit_epilogue ( Lam * lam)
overridevirtual

◆ find_kernels()

void mim::plug::nvptx::HostEmitter::find_kernels ( const Def * def)

Definition at line 144 of file nvptx.cpp.

References mim::Def::deps(), find_kernels(), and mim::Axm::isa().

Referenced by find_kernels(), and start().

◆ isa_targetspecific_intrinsic()

◆ prepare()

std::string mim::plug::nvptx::HostEmitter::prepare ( )
overridevirtual

◆ start()

void mim::plug::nvptx::HostEmitter::start ( )
finalvirtual

The documentation for this class was generated from the following file: