Legendary
Every weapon that deteriorates and can be repaired (That means, all weapons but consumable ones like one-time rocket launchers and grenades), gain experience in battle. PvP during Zone Control gives by far the biggest amount of experience and is almost the sole way of leveling up a legendary reliably and quickly. Once it has gained enough experience, it can be leveled up, at which point you are able to rename your weapon and give it an additional perk out of a list of perks for that specific weapon type. Your name will also be embedded in the weapon's description, meaning everyone will know you leveled it up.
Consecutive level ups will additionally display the names of people who had done so with this weapon. If for some reason you lose your weapon during level 1, and someone else will level it up to level 2, both you and the other's name will be displayed on the weapon.
This makes it worthwhile to take care of your weapon and repair it as need be - due to the fact that you can construct a very powerful version of the weapon you are using, by giving it a perk of your choice every time you level it up. The maximum level a weapon can become is 5, which is quite hard to achieve however, as every level needs more and more experience. Perks are exclusively-unique, meaning you can only take a perk once during the 5 levels, and you have to take other perks for the other 4 levels. (In other words, you can not take a perk twice). You CAN however take a perk that the weapon already has by default. You can only not take a perk on later levels you have taken on previous levels.
Leveling up a weapon
Once a weapon has reached enough XP to raise a level, you can level it up. If it is its first level (Level 1), you will first have to give it a name. This is done by cycling through the Firemodes with N until you find the firemode. Using it will allow you to give your weapon a unique name. It has to be unique and can not conflict with another legendary name. It has a maximum character size - but otherwise no restrictions. For each consecutive level, you will have to cycle through the firemodes until you get the choice.