llvm 0.0.8

  • README.md
  • Example
  • Installing
  • Versions
  • 10

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]
50
Overall:
Weighted score of the above. [more]
10
Learn more about scoring.

We analyzed this package on Sep 25, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0
  • pana: 0.12.3

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Issues and suggestions

Fix platform conflicts.

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

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 random_string any which requires SDK version >=1.0.0 <2.0.0, version solving failed.

Maintain CHANGELOG.md.

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

Package is pre-v0.1 release.

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.

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.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.19.0