llvm 0.0.8

llvm #

Support for generating LLVM IR, and using the LLVM toolchain within Dart.

example/main.dart

/// Based on the tutorial found [here](http://releases.llvm.org/2.6/docs/tutorial/JITTutorial1.html).
library llvm.example.a_first_function;

import 'package:indenting_buffer/indenting_buffer.dart';
import 'package:llvm/llvm.dart';

main() {
  var mod = new LlvmModule('test');

  // %define i32 mul_add(i32 %x, i32 %y, i32 %z)
  var mulAdd = new LlvmFunction('mul_add', returnType: LlvmType.i32);
  mulAdd.parameters.addAll([
    new LlvmParameter('x', LlvmType.i32),
    new LlvmParameter('y', LlvmType.i32),
    new LlvmParameter('z', LlvmType.i32)
  ]);

  // entry:
  var basicBlock = new LlvmBasicBlock('entry', mulAdd);

  // %tmp = mul i32 %x, %y
  var tmp = new LlvmValue('tmp');
  basicBlock.addStatement(tmp.assign(new LlvmBinaryExpression(
      Instruction.mul,
      new LlvmValue.reference('x', LlvmType.i32),
      new LlvmValue.reference('y', LlvmType.i32))));

  // %tmp2 = add i32 %x, %y
  var tmp2 = new LlvmValue('tmp2');
  basicBlock.addStatement(tmp2.assign(new LlvmBinaryExpression(
      Instruction.add, tmp, new LlvmValue.reference('z', LlvmType.i32))));

  // %ret i32 %tmp2
  basicBlock.addStatement(tmp2.asReturn());

  mulAdd.blocks.add(basicBlock);
  mod.functions.add(mulAdd);

  var buf = new IndentingBuffer();
  mod.compile(buf);

  var ir = buf.toString();
  print('Generated LLVM IR:\n');
  print(ir);
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  llvm: ^0.0.8

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:llvm/llvm.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
0
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://dart.dev/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0