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]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
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

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 
 Because llvm depends on indenting_buffer any which requires SDK version <2.0.0, version solving failed.

Health suggestions

Format lib/src/ast/binary.dart.

Run dartfmt to format lib/src/ast/binary.dart.

Format lib/src/ast/block.dart.

Run dartfmt to format lib/src/ast/block.dart.

Format lib/src/ast/call.dart.

Run dartfmt to format lib/src/ast/call.dart.

Fix additional 6 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/ast/constant.dart (Run dartfmt to format lib/src/ast/constant.dart.)
  • lib/src/ast/declare.dart (Run dartfmt to format lib/src/ast/declare.dart.)
  • lib/src/ast/expression.dart (Run dartfmt to format lib/src/ast/expression.dart.)
  • lib/src/ast/statement.dart (Run dartfmt to format lib/src/ast/statement.dart.)
  • lib/src/ast/type.dart (Run dartfmt to format lib/src/ast/type.dart.)
  • lib/src/toolchain/toolchain.dart (Run dartfmt to format lib/src/toolchain/toolchain.dart.)

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Package is getting outdated.

The package was released 52 weeks ago.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0