瀏覽代碼

* converted emitting pwidechar typed constants to the typed constant builder

git-svn-id: branches/hlcgllvm@28141 -
Jonas Maebe 11 年之前
父節點
當前提交
b94a524556
共有 2 個文件被更改,包括 24 次插入7 次删除
  1. 2 1
      compiler/aasmcnst.pas
  2. 22 6
      compiler/ngtcon.pas

+ 2 - 1
compiler/aasmcnst.pas

@@ -393,7 +393,8 @@ implementation
        maybe_new_object_file(prelist);
        { only now add items based on the symbolname, because it may be
          modified by the "section" specifier in case of a typed constant }
-       new_section(prelist,section,secname,const_align(alignment));
+       if section<>sec_none then
+         new_section(prelist,section,secname,const_align(alignment));
        if not lab then
          if sym.bind=AB_GLOBAL then
            prelist.concat(tai_symbol.Create_Global(sym,0))

+ 22 - 6
compiler/ngtcon.pas

@@ -884,22 +884,38 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
           if is_widechar(def.pointeddef) and
              (node.nodetype<>addrn) then
             begin
-              current_asmdata.getdatalabel(ll);
-              ftcb.emit_tai(Tai_const.Create_sym(ll),def);
-              current_asmdata.asmlists[al_typedconsts].concat(tai_align.create(const_align(sizeof(pint))));
-              current_asmdata.asmlists[al_typedconsts].concat(Tai_label.Create(ll));
               if (node.nodetype in [stringconstn,ordconstn]) then
                 begin
+                  current_asmdata.getdatalabel(ll);
                   { convert to unicodestring stringconstn }
                   inserttypeconv(node,cunicodestringtype);
                   if (node.nodetype=stringconstn) and
                      (tstringconstnode(node).cst_type in [cst_widestring,cst_unicodestring]) then
                    begin
+                     { create a tcb for the string data (it's placed in a separate
+                       asmlist) }
+                     datatcb:=ctai_typedconstbuilder.create;
                      pw:=pcompilerwidestring(tstringconstnode(node).value_str);
+                     { include terminating #0 }
+                     datadef:=getarraydef(cwidechartype,tstringconstnode(node).len+1);
+                     datatcb.maybe_begin_aggregate(datadef);
                      for i:=0 to tstringconstnode(node).len-1 do
-                       current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(pw^.data[i]));
+                       datatcb.emit_tai(Tai_const.Create_16bit(pw^.data[i]),cwidechartype);
                      { ending #0 }
-                     current_asmdata.asmlists[al_typedconsts].concat(Tai_const.Create_16bit(0))
+                     datatcb.emit_tai(Tai_const.Create_16bit(0),cwidechartype);
+                     datatcb.maybe_end_aggregate(datadef);
+                     { concat add the string data to the al_const asmlist }
+                     current_asmdata.asmlists[al_const].concatlist(datatcb.get_final_asmlist(ll,datadef,sec_rodata,ll.name,const_align(sizeof(pint)),true));
+                     datatcb.free;
+                     { we now emit the address of the first element of the array
+                       containing the string data }
+                     ftcb.queue_init(def);
+                     { address of ... }
+                     ftcb.queue_addrn(def.pointeddef,def);
+                     { ... the first element ... }
+                     ftcb.queue_vecn(datadef,0);
+                     { ... of the string array }
+                     ftcb.queue_emit_asmsym(ll,datadef);
                    end;
                 end
               else