aboutsummaryrefslogtreecommitdiffstats
path: root/lib/hipe/misc/hipe_consttab.erl
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-03-27 17:05:11 +0200
committerGitHub <[email protected]>2017-03-27 17:05:11 +0200
commit173cc4865cf0183242904283ea68626b5900ff08 (patch)
tree2ac8440d1e3881e61ef5c4a07e85c2704d722a96 /lib/hipe/misc/hipe_consttab.erl
parent236f2cecd0b0d8116c000187780f3981e6e9b388 (diff)
parent54d3e3ae0021f8277322ce51168829aa0dd67de1 (diff)
downloadotp-173cc4865cf0183242904283ea68626b5900ff08.tar.gz
otp-173cc4865cf0183242904283ea68626b5900ff08.tar.bz2
otp-173cc4865cf0183242904283ea68626b5900ff08.zip
Merge PR-1386 from kostis/hipe-const-alignment OTP-14302
hipe: Fix alignment of byte-sized constants
Diffstat (limited to 'lib/hipe/misc/hipe_consttab.erl')
-rw-r--r--lib/hipe/misc/hipe_consttab.erl15
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/hipe/misc/hipe_consttab.erl b/lib/hipe/misc/hipe_consttab.erl
index 64e3d3ccaa..741bdb2094 100644
--- a/lib/hipe/misc/hipe_consttab.erl
+++ b/lib/hipe/misc/hipe_consttab.erl
@@ -63,9 +63,7 @@
%% A hipe_consttab is a tuple {Data, ReferedLabels, NextConstLabel}
%% @type hipe_constlbl().
%% An abstract datatype for referring to data.
-%% @type element_type() = byte | word | ctab_array()
-%% @type ctab_array() = {ctab_array, Type::element_type(),
-%% NoElements::pos_integer()}
+%% @type element_type() = byte | word
%% @type block() = [integer() | label_ref()]
%% @type label_ref() = {label, Label::code_label()}
%% @type code_label() = hipe_sparc:label_name() | hipe_x86:label_name()
@@ -110,8 +108,7 @@
-type label_ref() :: {'label', code_label()}.
-type block() :: [hipe_constlbl() | label_ref()].
--type ctab_array() :: {'ctab_array', 'byte' | 'word', pos_integer()}.
--type element_type() :: 'byte' | 'word' | ctab_array().
+-type element_type() :: 'byte' | 'word'.
-type sort_order() :: term(). % XXX: FIXME
@@ -187,7 +184,7 @@ insert_block({ConstTab, RefToLabels, NextLabel}, ElementType, InitList) ->
ReferredLabels = get_labels(InitList, []),
NewRefTo = ReferredLabels ++ RefToLabels,
{NewTa, Id} = insert_const({ConstTab, NewRefTo, NextLabel},
- block, word_size(), false,
+ block, size_of(ElementType), false,
{ElementType,InitList}),
{insert_backrefs(NewTa, Id, ReferredLabels), Id}.
@@ -256,13 +253,9 @@ get_labels([], Acc) ->
%% @spec size_of(element_type()) -> pos_integer()
%% @doc Returns the size in bytes of an element_type.
-%% The is_atom/1 guard in the clause handling arrays
-%% constraints the argument to 'byte' | 'word'
-spec size_of(element_type()) -> pos_integer().
size_of(byte) -> 1;
-size_of(word) -> word_size();
-size_of({ctab_array,S,N}) when is_atom(S), is_integer(N), N > 0 ->
- N * size_of(S).
+size_of(word) -> word_size().
%% @spec decompose({element_type(), block()}) -> [byte()]
%% @doc Turns a block into a list of bytes.