llvm 0.0.8

  • README.md
  • Example
  • Installing
  • Versions
  • 0

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';
  
Version Uploaded Documentation Archive
0.0.8 Nov 21, 2017 Go to the documentation of llvm 0.0.8 Download llvm 0.0.8 archive
0.0.7 Nov 21, 2017 Go to the documentation of llvm 0.0.7 Download llvm 0.0.7 archive
0.0.6 Nov 21, 2017 Go to the documentation of llvm 0.0.6 Download llvm 0.0.6 archive
0.0.5 Nov 21, 2017 Go to the documentation of llvm 0.0.5 Download llvm 0.0.5 archive
0.0.4 Nov 21, 2017 Go to the documentation of llvm 0.0.4 Download llvm 0.0.4 archive
0.0.3 Nov 21, 2017 Go to the documentation of llvm 0.0.3 Download llvm 0.0.3 archive
0.0.2 Nov 21, 2017 Go to the documentation of llvm 0.0.2 Download llvm 0.0.2 archive
0.0.1 Nov 21, 2017 Go to the documentation of llvm 0.0.1 Download llvm 0.0.1 archive
0.0.0 Nov 18, 2017 Go to the documentation of llvm 0.0.0 Download llvm 0.0.0 archive
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://www.dartlang.org/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