comparison gen/d-asm-i386.h @ 304:3ebc136702dd trunk

[svn r325] Removed dead code. Added license info to code from GDC (David Friedman permitted us to use the files under the Artistic License). Added asmLabel check to DtoGoto to avoid jumping into inline asm. Doesn't work currently as LabelDsymbol::asmLabel is never set to true.
author ChristianK
date Wed, 25 Jun 2008 23:42:38 +0200
parents bef811104734
children 2b72433d5c8c
comparison
equal deleted inserted replaced
303:4aa2b6753059 304:3ebc136702dd
1 // Taken from GDC source, GPL! 1 // Taken from GDC source tree. Original by David Friedman.
2 // Released under the Artistic License found in dmd/artistic.txt
2 3
3 #include "dmd/id.h" 4 #include "dmd/id.h"
4 5
5 typedef enum { 6 typedef enum {
6 Reg_Invalid = -1, 7 Reg_Invalid = -1,
1416 insnTemplate->printf("<<%s%d>>", (mode==Mode_Input)?"in":"out", asmcode->args.dim); 1417 insnTemplate->printf("<<%s%d>>", (mode==Mode_Input)?"in":"out", asmcode->args.dim);
1417 insnTemplate->writestring((char*) fmtpost); 1418 insnTemplate->writestring((char*) fmtpost);
1418 asmcode->args.push( new AsmArg(type, e, mode) ); 1419 asmcode->args.push( new AsmArg(type, e, mode) );
1419 } 1420 }
1420 1421
1421 void addLabel(unsigned n) {
1422 // No longer taking the address of the actual label -- doesn't seem like it would help.
1423 char buf[64];
1424
1425 d_format_priv_asm_label(buf, n);
1426 insnTemplate->writestring(buf);
1427 }
1428
1429 void addLabel(char* id) { 1422 void addLabel(char* id) {
1430 //insnTemplate->writestring(".LDASM_");
1431 insnTemplate->writestring(id); 1423 insnTemplate->writestring(id);
1432 } 1424 }
1433 1425
1434 /* Determines whether the operand is a register, memory reference 1426 /* Determines whether the operand is a register, memory reference
1435 or immediate. Immediate addresses are currently classified as 1427 or immediate. Immediate addresses are currently classified as
1904 1896
1905 In order to get the correct output for function and label symbols, 1897 In order to get the correct output for function and label symbols,
1906 the %an format must be used with the "p" constraint. 1898 the %an format must be used with the "p" constraint.
1907 */ 1899 */
1908 if (isDollar(e)) { 1900 if (isDollar(e)) {
1909 unsigned lbl_num = ++d_priv_asm_label_serial; 1901 error("dollar labels are not supported", stmt->loc.toChars());
1910 addLabel(lbl_num); 1902 asmcode->dollarLabel = 1;
1911 asmcode->dollarLabel = lbl_num; // could make the dollar label part of the same asm..
1912 } else if (e->op == TOKdsymbol) { 1903 } else if (e->op == TOKdsymbol) {
1913 LabelDsymbol * lbl = (LabelDsymbol *) ((DsymbolExp *) e)->s; 1904 LabelDsymbol * lbl = (LabelDsymbol *) ((DsymbolExp *) e)->s;
1914 // this can probably be removed
1915 if (! lbl->asmLabelNum)
1916 lbl->asmLabelNum = ++d_priv_asm_label_serial;
1917
1918 stmt->isBranchToLabel = lbl; 1905 stmt->isBranchToLabel = lbl;
1919 1906
1920 use_star = false; 1907 use_star = false;
1921 addLabel(lbl->ident->toChars()); 1908 addLabel(lbl->ident->toChars());
1922 } else if ((decl && decl->isCodeseg())) { // if function or label 1909 } else if ((decl && decl->isCodeseg())) { // if function or label