dimitriv / Ziria

A domain-specific-language and compiler for low-level bitstream processing.
92 stars 18 forks source link

Long arrays in structs take lot of time to compile in Ziria/VS #115

Closed bradunov closed 8 years ago

bradunov commented 8 years ago

There is a weird array initialization that happens in the interpreter, and which initializes uninitialized arrays for no reason. Here is an example. The following code:

struct TXParams = {
  pdsch : arr[20] bit
};

fun configTX() {
  var params : struct TXParams;
  return params;
};

let comp main = read[bit] >>> write

gets compiled into the following (dump-fold-2):

struct  TXParams = pdsch: arr[20] bit
in
fun configTX{_r1}() =
      TXParams {pdsch = {'0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0, '0}}
in
(read[bit] >>>
 write[bit])

This initialization is not required at this stage. Firstly, initialization of ordinary arrays happens in Codegen and not in Interpreter, so there is no need that these arrays get initialized here. Often these arrays are very large and tremendously slow down compilation. Secondly, we may have different ways to initialize these array and it is better to have the array initialization code unified in Codegen.