-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new features for __emit #346
Comments
Would it be possible to have compile time evaluation of Instead of The number would be evaluated at compile time and return. If the symbol is global, no instructions are written. If it was a local, maybe output the last constant value with |
If by "where it is possible" you mean in constant expressions, then yes, I think this should be possible. But functions would be required to be implemented before the point of their use in
|
I'dmuch prefer this as something like |
Actually, there is this, #348, and possibly other required meta data like #pragma meta name MyFunc Which can then be combined with #define nameof(%0) __Pragma meta name %0 Yes, the original becomes a bit more verbose, but less intrusive and definable. Or, since pragmas are instructions:
Or something else, I don't like the symbols used for "name" and "address" in that code, but it's a rough idea. |
While Any help with phrasing a proper error description instead of
|
There is error 50 - "invalid range", 32 - "array index is out of bounds", and 28 - "invalid subscript (not an array or too many subscripts)". None are quite right, but good examples, giving something like "parameter is out of bounds". Would also need a way to specify lctrl 7 and 8 as valid (for JIT and crashdetect), maybe |
That's my whole point. None of the existing errors are quite correct for this situation, so we probably need to add a new one. Speaking of which, how about
That's already been taken care of, |
"Parameter" instead of "ID" to be more generic to any instruction, but otherwise yes. And my point was more that plugins can add more. Yes 7-9 are covered, but there could be more in the future that should be specifiable. |
Since |
I wanted to use "parameter" at first too, but it sounds too generic, it can mean anything (data address, stack offset, function address, label) while the error in question is supposed to be issued only for instructions
Probably would be better to keep everything simple and just disable that check for |
It is only used for those instructions currently - with "parameter" it could be applied to others as well. Or if not parameter, not ID either - they aren't identifiers in most of those cases. I suppose the correct term is "operand". |
Not sure what you mean. There's no need to apply this error to other instructions as they already have this: new var;
emit stor.pri var; // error 001: expected token: "-data offset-", but found "-local variable-" which is much more informative IMO, as it also tells about operand types. |
Oh, ok. |
In retrospect I can see the use of having some sort of address psudo-op, assuming that it can do locals and arrays as well. Currently there's no good way to do this in inline assembly: stock _YSI_ConstMod(const &var, const val)
{
#pragma unused var, val
#emit LOAD.S.pri val
#emit SREF.S.pri var
} The compiler generates all the correct code for calling the function regardless of the type of _YSI_ConstMod(localVar, 5);
_YSI_ConstMod(globalVar, 6);
_YSI_ConstMod(array[5][6], 7); All those require different addressing OPs - #define _YSI_ConstMod(%0,%1) \
__emit PSUDO.ADDR.alt %0 \
__emit CONST.alt %1 \
__emit STOR.I |
Kinda funny seeing that such "pseudo"-instructions could be useful, since I already experimented with a similar idea last year, but left it since I thought those instructions would never be useful to anyone. The idea about pseudo-instructions as a whole is not really new - you can already use
This is one of the features that was implemented in #211. And, as I already said, after implementing that feature I experimented with the idea of pseudo-instructions which could compile into different instructions depending on the types of their arguments, and ended up implementing two instructions called "load.u.pri/alt" and "stor.u.pri/alt" (the "u" stands for "unified"; I'm not a native English speaker though, so I'm pretty sure there might be better fitting alternatives to that word). I haven't seen the feature with macro-to-non-macro instructions I mentioned earlier being used anywhere, so I figured pseudo-instructions wouldn't be of much use as well and left them in a local repo with only the two abovementioned instructions implemented. But if such instructions could really be useful, I can always pick up the old implementation and finish it. |
Here's a full list of instructions I was going to implement.
|
@Y-Less The arguments of type "array" are not listed in the table above since I don't know how to handle them exactly for the following reasons:
|
I see what you're trying to do, but I'm not convinced by the excessive code involved in the "reference" variants:
|
I'm not sure where the compiler code for generating array access is, but if there's an easily reusable section, I'd say use that and let it add |
Aren't you mistaking stack for heap? You don't have to pre-allocate space in the stack to push values there.
As I already said, I only implemented
Ok then. Too bad we don't have the source for the documentation (pawn-lang.pdf, pawn-imp.pdf) to add new info to the opcode table. For now I'll add notes to the table in a post above under instructions that modify the registers and remove the code for register saving/restoring. |
No, I mean: push.alt // stack now -4
push.alt // stack now -8
stack <cellsize * 2> // stack now -0, data just pushed invalidated
lref.s.alt <refvar> // irrelevant
push.alt // stack now -4
stack <-cellsize> // stack again -8, but no guarantee of contents
pop.alt // popping garbage memory |
... Where exactly does this come from? Pawn Implementer's Guide clearly states that "the heap and the stack share a memory block", so the memory between the heap and the stack won't go anywhere. |
But the memory between the stack and the heap is not part of either the stack or the heap - it is garbage memory. I know for a fact that the JIT implementation stores data in there while calling natives at least, because it has no reason not to. |
Is this a BUG REPORT, FEATURE REQUEST or QUESTION?:
What happened:
I have a few ideas for the
__emit
operator, but before implementing them and making a PR I guess it would be better to discuss them here first.__emit dump <identifier>
.This would allow the compiler to retrieve addresses of functions, variables etc. as constant values, which could be useful for initialization of constants and immutable arrays.
Example:
Though I'm not sure if
dump
would be a proper pseudo-instruction name because in compiler assembly outputdump
means "put value(s) into the data section", not "retrieve symbol value/address".Since the next release is going to have naked functions without prologue and epilogue code, maybe we should allow such functions as arguments for jump instructions?
This would require addition of new error in
sc5.c
though (would "not a multiple of cell size" be a good description for it?)lctrl
,sctrl
and other instructions.Currently this would make the compiler issue an "invalid range" error, which clearly isn't the right description. But again, I'm not sure how to phrase that error properly.
What you expected to happen:
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Special thanks to @VVWVV for giving me the idea about the "not a multiple of cell size" error.
Environment:
The text was updated successfully, but these errors were encountered: