Task #7678

Generation of LLVM configuration files from nML specifications

Added by Andrei Tatarnikov over 4 years ago. Updated about 1 year ago.

Target version:
Start date:
Due date:
% Done:


Estimated time:
Detected in build:
Published in build:


Subject. To solve this task, you need implement an extension in Java that will traverse nML IR and generated the required files.

Such extensions implement the TranslatorHandler interface and are registered in the constuctor of the NmlTranslator class (see the code fragment below).

public final class NmlTranslator extends Translator<Ir> {
  private static final Set<String> FILTER = Collections.singleton(".nml");
  public NmlTranslator() {

    getSymbols().defineReserved(NmlSymbolKind.KEYWORD, ReservedKeywords.JAVA);
    getSymbols().defineReserved(NmlSymbolKind.KEYWORD, ReservedKeywords.RUBY);

    // Detects parent-child connections between primitives
    addHandler(new ReferenceDetector());
    // Adds the list of root operations to IR 
    addHandler(new RootDetector());

    addHandler(new ArgumentModeDetector());
    addHandler(new BranchDetector());
    addHandler(new MemoryAccessDetector());
    addHandler(new Analyzer(this));
    addHandler(new PrimitiveSyntesizer(this));
    addHandler(new ExceptionDetector());

    // Generate Java code of the ISA model
    addHandler(new MetaDataGenerator(this));
    addHandler(new Generator(this));

All these handlers are examples of how to implement logic traversing IR. Some of them perform analysis and some generate code. Code generation is done using the StringTemplate library (STG files + java classes).

To traverse the IR, the following classes and interfaces can be used: IrVisitor, IrVisitorDefault and IrWalker (or its variations IrWalkerFlow, IrWalkerShortcuts) defined in the package. You need to implement IrVisitor (use IrVisitorDefault as default implementation with empty methods) and pass it to the most suitable walker. NOTE: implementation of IR walker and visitor is raw and a subject to improvements. Any questions/feedback are appreciated.

Expressions require using a separate walker and visitor implemented in Fortress: ExprTreeVisitor, ExprTreeVisitorDefault and ExprTreeWalker (ru.ispras.fortress.expression). Examples of using them you can find both in MicroTESK and in Fortress.



Updated by Alexander Kamkin about 1 year ago

  • Target version changed from 2.4 to 2.5
  • Priority changed from Normal to Low
  • Assignee changed from Alexander Ulyanov to Alexander Kamkin
  • Category set to LLVM

Also available in: Atom PDF