Skip to content

InstructionInvocation

INCLUDE FILE
#include "InstructionInvocation.h"

class InstructionInvocation

Represents an invocation of an instruction.

It can produce the Body encoding the invocation.

DEFINITION
class InstructionInvocation;

class Argumentprivate

DEFINITION
class Argument;

constructor Argument

DEFINITION
Argument ( const AddressingMode::Argument * definition,
Node * node = nullptr );
PARAMETERDESCRIPTION
definition
node

method constraint_expressionconst

DEFINITION
std::optional< Expression >  constraint_expression ( const Location & location,
Symbol  name ) const;
PARAMETERDESCRIPTION
location
name
RETURNSDESCRIPTION
std::optional< Expression >

method known_invalidconst

DEFINITION
bool  known_invalid ( ) const;
RETURNSDESCRIPTION
bool

method known_validconst

DEFINITION
bool  known_valid ( ) const;
RETURNSDESCRIPTION
bool

member definition

DEFINITION
const AddressingMode::Argument * definition;

member known_value

DEFINITION
std::optional< Value >  known_value;

member valid

DEFINITION
std::optional< bool >  valid;

class Variantprivate

DEFINITION
class Variant;

constructor Variant

DEFINITION
Variant ( uint64_t  opcode,
const AddressingMode & addressing_mode,
const AddressingMode::Notation & notation,
const std::vector< std::shared_ptr< Node > > & nodes );
PARAMETERDESCRIPTION
opcode
addressing_mode
notation
nodes

method encodeconst

Encode the instruction variant.

DEFINITION
std::pair< std::optional< Expression >, Body >  encode ( const std::shared_ptr< Scope > & containing_scope ) const;
PARAMETERDESCRIPTION
containing_scope

The scope containing the instruction invocation.

RETURNSDESCRIPTION
std::pair< std::optional< Expression >, Body >

A pair containing an optional constraint expression and the encoded body.

method validconst

Check if the instruction variant is valid.

It is considered invalid if any of the arguments do not meet their type constraints.

DEFINITION
bool  valid ( ) const;
RETURNSDESCRIPTION
bool

true if the variant is valid, false otherwise.

member addressing_mode

The addressing mode of the instruction variant.

DEFINITION
std::reference_wrapper< const AddressingMode >  addressing_mode;

member argument_aliases

The arguments that have been renamed due to different names in other variants.

This is filled in by InstructionInvocation::compute_argument_names().

The key is the original name, and the value is renamed name.

DEFINITION
std::unordered_map< Symbol, Symbol >  argument_aliases;

member arguments

The arguments of the invocation, indexed by name.

DEFINITION
std::unordered_map< Symbol, Argument >  arguments;

member nodes

The parsed arguments of the instruction invocation.

DEFINITION
std::reference_wrapper< const std::vector< std::shared_ptr< Node > > >  nodes;

member notation

The notation of the instruction variant.

DEFINITION
std::reference_wrapper< const AddressingMode::Notation >  notation;

member opcode

The opcode of the instruction variant.

DEFINITION
uint64_t  opcode;

member unknown_argument_names

The names of arguments with unknown values, indexed by their position in the argument list.

DEFINITION
std::unordered_map< size_t, Symbol >  unknown_argument_names;

member valid_

If the variant is valid.

DEFINITION
bool  valid_;

constructor InstructionInvocation

Construct an InstructionInvocation.

DEFINITION
InstructionInvocation ( const CPU * ,
Token  name,
const std::vector< std::shared_ptr< Node > > & nodes,
const std::shared_ptr< Scope > & containing_scope );
PARAMETERDESCRIPTION
name

The name of the instruction.

nodes

The parsed nodes representing the arguments of the invocation.

containing_scope

The scope containing the invocation.

method add_pc

Add the program counter (PC) to the instruction invocation.

DEFINITION
void  add_pc ( Expression  pc );
PARAMETERDESCRIPTION
pc

The PC constant to add.

method compute_argument_namesprivate

Compute the names of the arguments in the instruction invocation.

This method populates the argument_names vector. If all variants have the same argument name at a position, it will get that name, otherwise it will get an internal name.

DEFINITION
void  compute_argument_names ( );

method encode

Encode the instruction invocation.

DEFINITION
Body  encode ( );
RETURNSDESCRIPTION
Body

The encoded body of the instruction invocation.

method uses_pc

Check if the instruction invocation uses the program counter (PC)..

DEFINITION
bool  uses_pc ( );
RETURNSDESCRIPTION
bool

true if the instruction invocation uses the PC, false otherwise.

member argument_namesprivate

The names of the arguments in the instruction invocation.

If an argument has a known value, its name in this list is the empty symbol.

DEFINITION
std::vector< Symbol >  argument_names;

member argumentsprivate

The arguments in the instruction invocation.

DEFINITION
std::vector< Expression >  arguments;

member containing_scopeprivate

The scope containing the instruction invocation.

DEFINITION
std::shared_ptr< Scope >  containing_scope;

member has_unknown_argumentsprivate

Whether the invocation has arguments with unknown values.

DEFINITION
bool  has_unknown_arguments;

member location

The location of the invocation in the source code.

DEFINITION
Location  location;

member nodesprivate

The parsed invocation line.

DEFINITION
std::vector< std::shared_ptr< Node > >  nodes;

member pcprivate

DEFINITION
std::optional< Expression >  pc;

member uses_pc_private

Whether the invocation uses the program counter (PC).

DEFINITION
bool  uses_pc_;

member variantsprivate

The variants of the instruction invocation.

DEFINITION
std::vector< Variant >  variants;

class Argumentprivate

DEFINITION
class Argument;

constructor Argument

DEFINITION
Argument ( const AddressingMode::Argument * definition,
Node * node = nullptr );
PARAMETERDESCRIPTION
definition
node

method constraint_expressionconst

DEFINITION
std::optional< Expression >  constraint_expression ( const Location & location,
Symbol  name ) const;
PARAMETERDESCRIPTION
location
name
RETURNSDESCRIPTION
std::optional< Expression >

method known_invalidconst

DEFINITION
bool  known_invalid ( ) const;
RETURNSDESCRIPTION
bool

method known_validconst

DEFINITION
bool  known_valid ( ) const;
RETURNSDESCRIPTION
bool

member definition

DEFINITION
const AddressingMode::Argument * definition;

member known_value

DEFINITION
std::optional< Value >  known_value;

member valid

DEFINITION
std::optional< bool >  valid;

class Variantprivate

DEFINITION
class Variant;

constructor Variant

DEFINITION
Variant ( uint64_t  opcode,
const AddressingMode & addressing_mode,
const AddressingMode::Notation & notation,
const std::vector< std::shared_ptr< Node > > & nodes );
PARAMETERDESCRIPTION
opcode
addressing_mode
notation
nodes

method encodeconst

Encode the instruction variant.

DEFINITION
std::pair< std::optional< Expression >, Body >  encode ( const std::shared_ptr< Scope > & containing_scope ) const;
PARAMETERDESCRIPTION
containing_scope

The scope containing the instruction invocation.

RETURNSDESCRIPTION
std::pair< std::optional< Expression >, Body >

A pair containing an optional constraint expression and the encoded body.

method validconst

Check if the instruction variant is valid.

It is considered invalid if any of the arguments do not meet their type constraints.

DEFINITION
bool  valid ( ) const;
RETURNSDESCRIPTION
bool

true if the variant is valid, false otherwise.

member addressing_mode

The addressing mode of the instruction variant.

DEFINITION
std::reference_wrapper< const AddressingMode >  addressing_mode;

member argument_aliases

The arguments that have been renamed due to different names in other variants.

This is filled in by InstructionInvocation::compute_argument_names().

The key is the original name, and the value is renamed name.

DEFINITION
std::unordered_map< Symbol, Symbol >  argument_aliases;

member arguments

The arguments of the invocation, indexed by name.

DEFINITION
std::unordered_map< Symbol, Argument >  arguments;

member nodes

The parsed arguments of the instruction invocation.

DEFINITION
std::reference_wrapper< const std::vector< std::shared_ptr< Node > > >  nodes;

member notation

The notation of the instruction variant.

DEFINITION
std::reference_wrapper< const AddressingMode::Notation >  notation;

member opcode

The opcode of the instruction variant.

DEFINITION
uint64_t  opcode;

member unknown_argument_names

The names of arguments with unknown values, indexed by their position in the argument list.

DEFINITION
std::unordered_map< size_t, Symbol >  unknown_argument_names;

member valid_

If the variant is valid.

DEFINITION
bool  valid_;