Task #5411
closed[template] Template constructs for data declaration
100%
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?- A construct(s) to declare data of different types (sizes):
byte
,hword
,word
, anddword
(e.g., see MIPS directives.word
,.asciiz
, etc.). - 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 be0
). - A mechanism to load addresses to registers (like
la
(load address) MIPS pseudo-instruction).
Updated by Andrei Tatarnikov about 10 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
Updated by Alexander Kamkin about 10 years ago
Непонятен смысл последнего параметра в define_space
и define_string
. Желательно бы по-наглядней сделать.
Updated by Andrei Tatarnikov about 10 years ago
Обновил синтаксис. Теперь все определения используют синтаксис ключ-значение.
Updated by Andrei Tatarnikov almost 10 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.
Updated by Andrei Tatarnikov almost 10 years ago
- Status changed from Resolved to Closed
- Published in build set to 141230