Project

General

Profile

Actions

Task #5411

closed

[template] Template constructs for data declaration

Added by Alexander Kamkin over 9 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
High
Assignee:
Andrei Tatarnikov
Category:
-
Target version:
Start date:
11/07/2014
Due date:
% Done:

100%

Estimated time:
Detected in build:
svn
Published in build:
141230

Description

There is an urgent need to declare data (variables, arrays, etc.) in test templates and to use them to describe test scenarios.

What do we need?
  1. A construct(s) to declare data of different types (sizes): byte, hword, word, and dword (e.g., see MIPS directives .word, .asciiz, etc.).
  2. A memory model that maps symbols to addresses (address of the i th item is calculated as follows: addr(item[i]) = addr(item[i-1]) + size(item[i-1]) + allignment; the first address is assumed to be 0).
  3. A mechanism to load addresses to registers (like la (load address) MIPS pseudo-instruction).
Actions #1

Updated by Andrei Tatarnikov over 9 years ago

  • Status changed from New to Open
Actions #2

Updated by Andrei Tatarnikov over 9 years ago

Примерный синтаксис (для семейства MIPS):

Определение конструкций для работы с данными:

data_config (:text => '.data', :target => 'M', :addressableSize => 8) {
  define_type  :id => :byte,     :text => '.byte',  :type => type('card', 8)
  define_type  :id => :halfword, :text => '.half',  :type => type('card', 16)
  define_type  :id => :word,     :text => '.word',  :type => type('card', 32)
  define_space :id => :space,    :text => '.space', :fillWith => 0

  define_ascii_string :id => :ascii,  :text => '.ascii',  :zeroTerm => false
  define_ascii_string :id => :asciiz, :text => '.asciiz', :zeroTerm => true
}

Объявления данных:

data {
  label :data1
  word 1, 2, 3, 4

  label :data2 
  half 0xDEAD, 0xBEEF

  label :hello
  ascii  "Hello" 

  label :world
  asciiz "World" 

  space 8
}

Обращения к данным (* la - псевдоинструкция, которую нужно описать):

la r(1), :data1
lw r(2), r(1), r(0)

Псевдоинструкция la (load address) описывается на nML:

op la(rd : REG, addr : WORD)
  syntax = format("la %s, %<label>d", rd.syntax, addr)
  image  = format("%s%s", lui(rd, addr<16..31>).image, ori(rd, rd, addr<0..15>).image)
  action = {
    instruction(lui(rd, addr<0..15>)).action;
    instruction(ori(rd, rd, addr<16..31>)).action;
  }
}

Выводится в текст программы как:

la $1, data

А выполняется как:

lui $1, 0xXXXX
ori $1, $1, 0xYYYY
Actions #3

Updated by Alexander Kamkin over 9 years ago

Непонятен смысл последнего параметра в define_space и define_string. Желательно бы по-наглядней сделать.

Actions #4

Updated by Andrei Tatarnikov over 9 years ago

Обновил синтаксис. Теперь все определения используют синтаксис ключ-значение.

Actions #5

Updated by Andrei Tatarnikov over 9 years ago

  • % Done changed from 0 to 20
Actions #6

Updated by Andrei Tatarnikov over 9 years ago

  • % Done changed from 20 to 30
Actions #7

Updated by Andrei Tatarnikov over 9 years ago

  • Status changed from Open to Resolved
  • % Done changed from 30 to 100

Implemented in r2951. May need a review in the future. Nevertheless, the current implementation supports all the specified syntax constructs and is capable of all the specified duties.

Actions #8

Updated by Andrei Tatarnikov over 9 years ago

  • Status changed from Resolved to Closed
  • Published in build set to 141230
Actions

Also available in: Atom PDF