From 224ee397db324067b35874bf22c76a63e9ca531b Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 27 Oct 2016 18:41:51 -0700 Subject: Plug holes where defaultCompileOptions leaked in defaultCompileOptions is convenient, but it frequently foils the compatibility layer by providing strict defaults rather than passing through the user's CompileOptions. This notably manifests for chiselCloneType, which has different behavior for chisel3 and Chisel. Ideally, we'd get rid of defaultCompileOptions within chisel3.core and only supply it to people who import chisel3._ (attn. @ucbjrl). That would statically prevent further regressions of this nature within the core. The change to Vec.truncateIndex seems extraneous, but I chose an alternate implementation rather than requiring compileOptions in another place. --- .../internal/sourceinfo/SourceInfoTransform.scala | 27 ++++++++++++++++++---- 1 file changed, 22 insertions(+), 5 deletions(-) (limited to 'coreMacros/src') diff --git a/coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala b/coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala index ba14b78f..7930138b 100644 --- a/coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala +++ b/coreMacros/src/main/scala/chisel3/internal/sourceinfo/SourceInfoTransform.scala @@ -24,13 +24,14 @@ trait SourceInfoTransformMacro { import c.universe._ def thisObj = c.prefix.tree def implicitSourceInfo = q"implicitly[_root_.chisel3.internal.sourceinfo.SourceInfo]" + def implicitCompileOptions = q"implicitly[_root_.chisel3.core.CompileOptions]" } class WireTransform(val c: Context) extends SourceInfoTransformMacro { import c.universe._ def apply[T: c.WeakTypeTag](t: c.Tree): c.Tree = { val tpe = weakTypeOf[T] - q"$thisObj.do_apply($t, null.asInstanceOf[$tpe])($implicitSourceInfo)" + q"$thisObj.do_apply($t, null.asInstanceOf[$tpe])($implicitSourceInfo, $implicitCompileOptions)" } } @@ -75,16 +76,16 @@ class MuxTransform(val c: Context) extends SourceInfoTransformMacro { class VecTransform(val c: Context) extends SourceInfoTransformMacro { import c.universe._ def apply_elts(elts: c.Tree): c.Tree = { - q"$thisObj.do_apply($elts)($implicitSourceInfo)" + q"$thisObj.do_apply($elts)($implicitSourceInfo, $implicitCompileOptions)" } def apply_elt0(elt0: c.Tree, elts: c.Tree*): c.Tree = { - q"$thisObj.do_apply($elt0, ..$elts)($implicitSourceInfo)" + q"$thisObj.do_apply($elt0, ..$elts)($implicitSourceInfo, $implicitCompileOptions)" } def tabulate(n: c.Tree)(gen: c.Tree): c.Tree = { - q"$thisObj.do_tabulate($n)($gen)($implicitSourceInfo)" + q"$thisObj.do_tabulate($n)($gen)($implicitSourceInfo, $implicitCompileOptions)" } def fill(n: c.Tree)(gen: c.Tree): c.Tree = { - q"$thisObj.do_fill($n)($gen)($implicitSourceInfo)" + q"$thisObj.do_fill($n)($gen)($implicitSourceInfo, $implicitCompileOptions)" } def contains(x: c.Tree)(ev: c.Tree): c.Tree = { q"$thisObj.do_contains($x)($implicitSourceInfo, $ev)" @@ -140,6 +141,22 @@ class SourceInfoTransform(val c: Context) extends AutoSourceTransform { } } +class CompileOptionsTransform(val c: Context) extends AutoSourceTransform { + import c.universe._ + + def thatArg(that: c.Tree): c.Tree = { + q"$thisObj.$doFuncTerm($that)($implicitSourceInfo, $implicitCompileOptions)" + } + + def inArg(in: c.Tree): c.Tree = { + q"$thisObj.$doFuncTerm($in)($implicitSourceInfo, $implicitCompileOptions)" + } + + def pArg(p: c.Tree): c.Tree = { + q"$thisObj.$doFuncTerm($p)($implicitSourceInfo, $implicitCompileOptions)" + } +} + /** Special whitebox version of the blackbox SourceInfoTransform, used when fun things need to happen to satisfy the * type system while preventing the use of macro overrides. */ -- cgit v1.2.3